Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows Server 系統教學 >> Server 2008

善用命令列提升 Windows Server 2008 管理效率 (ServerManagerCmd 與 Netsh 實戰)

編輯:Server 2008

ServerManagerCmd.exe - 角色/功能命令列管理

支援查詢、安裝、移除角色、角色服務、功能,適合腳本自動化部署。

常用參數

  • -query:列出已安裝/可用角色與功能 (綠色 [X] 表已裝)。
  • -install <Name> [-resultPath file.xml] [-restart]:安裝指定功能 (需英文名稱,如 Telnet-Client)。
  • -remove <Name1> <Name2> ...:移除多個角色/功能。

實例

# 查詢並管道過濾
ServerManagerCmd.exe -query | findstr GPMC

# 安裝 Telnet 用戶端並記錄結果
ServerManagerCmd.exe -install Telnet-Client -resultPath installResult.xml

# 同時移除 WDS 角色與 TFTP 用戶端
ServerManagerCmd.exe -remove WDS TFTP-Client

Netsh - 快速配置防火牆規則

查看狀態

netsh firewall show state

啟用/停用防火牆

netsh firewall set opmode enable
netsh firewall set opmode disable

開放 DNS (UDP 53)、檔案列印共享 (UDP 137/138, TCP 139/445)

netsh firewall add portopening UDP 53 "DNS-Server"
netsh firewall add portopening UDP 137 "NetBIOS-NS"
netsh firewall add portopening UDP 138 "NetBIOS-DGM"
netsh firewall add portopening TCP 139 "NetBIOS-SSN"
netsh firewall add portopening TCP 445 "NetBIOS-DS"

命令列操作不僅效率高、可腳本化,更能在 Server Core 無 GUI 環境下完整管理伺服器。

Copyright © Windows教程網 All Rights Reserved