PowerShell 2.0 從 Windows 移除

套用到
Windows 11 SE, version 24H2 Windows 11 Enterprise and Education, version 24H2 Windows 11 Enterprise Multi-Session, version 24H2 Windows 11 Home and Pro, version 24H2 Windows 11 IoT Enterprise, version 24H2 Windows Server 2025

注意

  • 原始發佈日期: 2025年8月11日
  • KB ID: 5065506

摘要

Windows PowerShell 2.0 是最初於 Windows 7 引入的舊有元件,將於即將推出的版本中從 Windows 作業系統 (作業系統) 中移除。 PowerShell 2.0 於 2017 年正式被棄用,並作為相容性選配功能繼續提供,詳見 Windows PowerShell 2.0 Deprecation 部落格。

PowerShell 2.0 將於 2025 年 8 月起在 Windows 11 版本 24H2 及 2025 年 9 月的 Windows Server 2025 版本中移除。 所有後續版本的 Windows 11 與 Windows Server 2025 將不再包含 PowerShell 2.0。 Windows Insider 預覽版 已經反映此變更,PowerShell 2.0 功能自 2025 年 7 月起已被移除。 這次移除是清理舊有程式碼、降低 PowerShell 生態系統複雜度及提升 Windows 安全性的更廣泛努力的一部分。

對大多數使用者和組織來說,這項變更不會發生什麼大事——像是 PowerShell 5.1 和 PowerShell 7.x 等新版本的 PowerShell 仍然可用並持續支援。 然而,如果你使用的是明確依賴 PowerShell 2.0 的舊腳本或軟體,就需要採取行動並更新它們,或使用替代方案來避免任何中斷。

本文提供了變更的時間軸、對不同使用者群的影響,以及如何緩解問題的指引。 
 

減緩指導

如果你的環境對 PowerShell 2.0 有依賴,以下是你可以減輕問題的方法:

  • 建議:將腳本和工具遷移到較新的 PowerShell 版本

    Microsoft 的主要指引是將所有使用 PowerShell 2.0 的程式碼更新為 PowerShell 5.1 或 PowerShell 7。 PowerShell 5.1 引入了許多改進,並且幾乎所有指令和模組都向下相容。 PowerShell 團隊部落格提供了這次遷移的指南。

  • 更新或替換過時的軟體

    在某些情況下,「解決方法」可能是升級需要 PowerShell 2.0 的軟體。 例如,如果舊的安裝程式失敗,就尋找該產品的更新版本。

    • 許多曾經使用 PowerShell 2.0 (Exchange、SharePoint、SQL 等的 Microsoft 伺服器產品,) 有更新版本,使用現代 PowerShell。 如果你打算在新版本的 Windows 上執行,請使用這些更新版本。
    • 如果是第三方工具,請查看廠商網站是否有更新或更新版本,移除了 PowerShell 2.0 的要求。 鑑於這種淘汰問題已存在多年,有些廠商可能已經處理過。
  • 暫時緩解
    ​​​​
    注意 這是解除封鎖用戶的臨時緩解措施。 你應該盡快從 PowerShell 2.0 遷移,並使用上述其他緩解措施。

    作為最後的暫時緩解措施,你可以透過以下步驟重新安裝 PowerShell 2.0:

    1. 下載 ps2DLC.zip 檔案。

    2. 將 ps2DLC.zip 檔案解壓到你選擇的資料夾。

    3. 在管理員模式下啟動一個 PowerShell 視窗。

    4. 將資料夾改為包含已解壓縮的 PowerShell 2.0 檔案的資料夾。

    5. 執行下列命令:

      注意

      run .\loadGAC.ps1

常見問題集

什麼是 PowerShell 2.0?

這是 Microsoft 已不再支援的舊版 PowerShell。

為什麼 PowerShell 2.0 要從 Windows 中移除?

PowerShell 2.0 於 2017 年正式被淘汰,現在正被移除,以鼓勵使用更新且更安全的 PowerShell 版本。

哪些 Windows 版本會受到影響?

PowerShell 2.0 將從 Windows 11、版本 24H2 及 Windows Server 2025 起被移除。

什麼時候會進行移除?

PowerShell 2.0 將於 2025 年 8 月起在 Windows 11 版本 24H2 及 2025 年 9 月的 Windows Server 2025 版本中移除。 所有後續版本的 Windows 11 與 Windows Server 2025 將不再包含 PowerShell 2.0。 Windows Insider 預覽版 已經反映此變更,PowerShell 2.0 功能自 2025 年 7 月起被移除,未來的 Insider 版本將不再包含此功能。

如果我有舊的腳本或程式需要 PowerShell 2.0,我該怎麼辦?

更新腳本或工具,使其能在較新的 PowerShell 版本上執行,例如 PowerShell 5.1 或 PowerShell 7。

如果我使用指定版本 2.0 的舊腳本或排程任務,會發生什麼事?

例如,如果腳本或排程任務明確嘗試透過像 powershell.exe -Version 2) 這樣的指令啟動 PowerShell 2.0 (,Windows 將無法再執行該舊有引擎。 系統會啟動預設的 PowerShell 版本,也就是 PowerShell 5.1) (。 大多數時候,腳本仍能正常運作,因為 PowerShell 5.1 是向下相容的。 然而,若某些舊腳本依賴 2.0 版本獨有的特定行為,仍有一小部分機率無法如預期執行。 建議的解決方案是更新這些腳本,移除這個 -Version 2 需求。

有沒有什麼情況會導致移除導致錯誤?

是的,但這類情況很少見。 例如,如果腳本或排程任務明確使用 PowerShell 2.0 (,且有 -version 2) ,Windows 將無法再執行該引擎。 這類腳本預設使用 PowerShell 5.1,且大多數情況下相容。 有些腳本如果依賴 2.0 獨有的特性,行為可能會不同。 解決方法是更新這些腳本,使其不再需要 -Version 2。 如果你需要額外協助,請聯絡 Microsoft 支援服務

如果安裝程式或應用程式尋找 PowerShell 2.0 會發生什麼事?

部分較舊的非 Windows 軟體可能會嘗試安裝或啟用 PowerShell 2.0。 在缺少 PowerShell 2.0 的新版本 Windows 上,安裝程式可能會失敗或顯示錯誤。 通常,這類軟體已過時且不支援最新 Windows 系統。 解決方法是使用不依賴 PowerShell 2.0 的更新軟體版本。