Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows Server 遷移工具移除指南:PowerShell 與 Server Core 雙模式操作

編輯:Windows XP 系統介紹

前言:什麼是 Windows Server 遷移工具?為什麼要移除?

Windows Server Migration Tools (WSMT) 允許將角色、功能、使用者、群組、設定從舊伺服器遷移至新伺服器。遷移完成後,工具本身佔用磁碟空間、擴大攻擊面、可能與新版本衝突。本文提供完整安裝版 (GUI)與Server Core (無 GUI)雙模式移除步驟,均以 PowerShell 為主,適合自動化腳本。注意:WSMT 移除不會影響已遷移的資料/設定。

模式一:完整安裝版 (Desktop Experience) — PowerShell 移除

前置條件

  • 以 Administrator 權限 執行 PowerShell (右鍵「以系統管理員身分執行」)
  • 確認已匯入 ServerManager 模組

步驟

# 1. 匯入 ServerManager 模組 (預設已載入,若無則執行)
Import-Module ServerManager

# 2. 確認目前安裝狀態
Get-WindowsFeature Migration

# 3. 移除遷移工具功能
Remove-WindowsFeature Migration -Restart:$false

# 4. 驗證移除結果
Get-WindowsFeature Migration | Format-Table Name, InstallState
# InstallState 應顯示 "Available" (未安裝)

替代方案:Server Manager GUI

  1. 開啟「伺服器管理員」→「管理」→「新增角色及功能」
  2. 「功能」頁籤 → 取消勾選「Windows Server 遷移工具」→ 下一步 → 移除
  3. 不需重開機

模式二:Server Core 安裝選項 — 三種等效移除路徑

Server Core 無 GUI,僅命令列。提供三種指令任選一,效果相同:

路徑 A:PowerShell 會話中移除 (推薦、可腳本化)

# 1. 進入 PowerShell
powershell

# 2. 匯入模組
Import-Module ServerManager

# 3. 移除
Remove-WindowsFeature Migration -Restart:$false

路徑 B:ocsetup 傳統指令 (相容舊腳本)

ocsetup ServerMigration /uninstall

路徑 C:pkgmgr 封裝管理器指令 (最底層)

pkgmgr /uu:ServerMigration

驗證移除 (任選一)


# PowerShell
Get-WindowsFeature Migration

# CMD
dism /online /get-features /format:table | findstr Migration
# State: Disabled / Removed 即成功

常見問題與避坑

問題原因解決
Remove-WindowsFeature 卡住/報錯有其他功能相依 Migration (極少見)檢查 Get-WindowsFeature | Where DependsOn -like "*Migration*",先移除相依功能
Server Core 下 ocsetup 無回應ocsetup 為非同步,需輪詢狀態用 dism /online /get-features 輪詢或直接用 Remove-WindowsFeature
移除後磁碟空間未釋放明顯WSMT 本身較小 (~50MB),主要空間在遷移暫存資料清理 C:\Windows\Migration\、%TEMP%\Migration* 目錄
誤以為移除工具會刪除已遷移資料工具與資料無關放心移除,遷移完成的角色/設定/資料不受影響

自動化部署範例 (Ansible/DSC/Intune)

PowerShell DSC 組態片段


Configuration RemoveMigrationTools {
    Node $AllNodes.Where({$_.Role -eq "Server"}).NodeName {
        WindowsFeature MigrationTools {
            Name = "Migration"
            Ensure = "Absent"
        }
    }
}

Ansible Task


- name: Remove Windows Server Migration Tools
  win_feature:
    name: Migration
    state: absent
  when: ansible_os_family == 'Windows'

結語

遷移工具屬於「一次性基建工具」,用完即走。掌握 Remove-WindowsFeature Migration (GUI/Core 通用)、ocsetup ServerMigration /uninstall、pkgmgr /uu:ServerMigration 三條等效路徑,將移除動作納入遷移專案收尾 Checklist、黃金映像建置腳本、合規性基線掃描,確保生產環境無殘留攻擊面、無多餘元件。乾淨的伺服器,才是安全的伺服器。

Copyright © Windows教程網 All Rights Reserved