Skill 详情
windows-server
Relevant infrastructure operations specialty, but focused on Windows Server administration.
使用前先检查
自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。
SKILL.md
这段内容是审核时保存的快照。外部来源才是完整且最新的版本。
---
name: windows-server
description: Administer Windows Server systems. Manage IIS, Active Directory, and PowerShell automation. Use when administering Windows infrastructure.
license: MIT
metadata:
author: devops-skills
version: "1.0"
---
# Windows Server Administration
Windows Server management and PowerShell automation for production workloads including IIS web hosting, Active Directory domain services, and system maintenance.
## When to Use
- Provisioning or configuring Windows Server 2019/2022 instances
- Setting up IIS websites, application pools, and bindings
- Managing Active Directory users, groups, and Group Policy
- Automating administrative tasks with PowerShell
- Reviewing Windows Event Logs for troubleshooting
- Applying and managing Windows Updates on servers
## Prerequisites
- Administrator account on the target server
- PowerShell 5.1+ (built-in) or PowerShell 7+ installed
- Remote Desktop or WinRM access configured
- Windows Server 2019 or 2022 (Desktop Experience or Server Core)
## PowerShell Administration Essentials
```powershell
# Check PowerShell version
$PSVersionTable.PSVersion
# Get system information
Get-ComputerInfo | Select-Object CsName, OsName, OsVersion, OsArchitecture
# List running processes sorted by CPU
Get-Process | Sort-Object CPU -Descending | Select-Object -First 20
# List all services and their status
Get-Service | Where-Object { $_.Status -eq 'Running' }
# Restart a service
Restart-Service -Name W3SVC -Force
# Get disk space on all drives
Get-PSDrive -PSProvider FileSystem | Select-Object Name, @{N='Used(GB)';E={[math]::Round($_.Used/1GB,2)}}, @{N='Free(GB)';E={[math]::Round($_.Free/1GB,2)}}
# Check uptime
(Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime
# Open firewall port
New-NetFirewallRule -DisplayName "Allow HTTPS" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow
# List firewall rules
Get-NetFirewallRule | Where-Object { $_.Enabled -eq 'True' -and $_.Direction -eq 'Inbound' } | Select-Object DisplayName, Action
# Set DNS client server addresses
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("10.0.0.2","10.0.0.3")
# PowerShell remoting to another server
Enter-PSSession -ComputerName server02 -Credential (Get-Credential)
# Run a command on multiple remote servers
Invoke-Command -ComputerName server01,server02,server03 -ScriptBlock { Get-Service W3SVC }
```
## Server Roles and Features
```powershell
# List all available roles and features
Get-WindowsFeature
# Install IIS with management tools
Install-WindowsFeature -Name Web-Server -IncludeManagementTools -IncludeAllSubFeature
# Install Active Directory Domain Services
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
# Install DNS Server
Install-WindowsFeature -Name DNS -IncludeManagementTools
# Install DHCP Server
Install-WindowsFeature -Name DHCP -IncludeManagementTools
# Install File Server with deduplication
Install-WindowsFeature -Name FS-FileServer, FS-Data-Deduplication
# List installed features only
Get-WindowsFeature | Where-Object Installed | Select-Object Name, InstallState
# Remove a feature
Uninstall-WindowsFeature -Name Telnet-Client
```
## IIS Web Server Setup
```powershell
# Import the IIS administration module
Import-Module WebAdministration
# Create a new application pool
New-WebAppPool -Name "ProductionPool"
Set-ItemProperty IIS:\AppPools\ProductionPool -Name processModel.identityType -Value 3 # NetworkService
Set-ItemProperty IIS:\AppPools\ProductionPool -Name managedRuntimeVersion -Value "" # No managed code (reverse proxy)
# Create a new website
New-Website -Name "MyApp" `
-Port 443 `
-Protocol https `
-PhysicalPath "C:\inetpub\myapp" `
-ApplicationPool "ProductionPool" `
-SslFlags 1
# Add an HTTP binding that redirects to HTTPS
New-WebBinding -Name "MyApp" -Protocol http -Port 80
# Bind an SSL certificate to the HTTPS site
$cert = Get-ChildItem -Path Cert:\LocalMachine\My | Wher在 GitHub 阅读完整来源 (打开外部页面)