使用 PowerShell 腳本檢查 Windows 11 硬件準備情況
在這篇文章中,我們將看看如何使用微軟官方硬件就緒.ps1用於在域計算機上執行批量 Windows 11 硬件兼容性檢查的 PowerShell 腳本。
此腳本檢查計算機是否滿足以下運行 Windows 11 的最低要求:
- 兼容的 x64 處理器(支持的 CPU 的完整列表)
- 4+ GB 內存
- 最小 64 GB 硬盤大小
- 啟用 UEFI 和安全啟動的設備
- 與 DirectX 12 和 WDDM 2.0 驅動程序兼容的顯卡
- TPM 2.0模塊
要手動檢查特定計算機的硬件是否與 Windows 11 要求兼容:
- 下載硬件就緒.ps1腳本 (https://aka.ms/HWReadinessScript)。
- 打開提升的 Windows PowerShell 控制台(該腳本使用
Get-WMIObjectcmdlet,最新版本的 PowerShell Core 不支持) - 在當前會話中啟用 PowerShell 腳本執行:
Set-ExecutionPolicy -Scope Process RemoteSigned - 運行腳本:
.HardwareReadiness.ps1

腳本已返回代碼0。這意味著您的計算機滿足 Windows 11 的硬件要求(returncode:0 , resurnresult=CAPABLE)。
{"returnCode":0,"returnReason":"","logging":"Storage: OSDiskSize=427GB. PASS; Memory: System_Memory=32GB. PASS; TPM: TPMVersion=2.0, 0, 1.38. PASS; Processor: {AddressWidth=64; MaxClockSpeed=3901; NumberOfLogicalCores=12; Manufacturer=AuthenticAMD; Caption=AMD64 Family 25 Model 80 Stepping 0; }. PASS; SecureBoot: Capable. PASS; ","returnResult":"CAPABLE"}
假設您需要在企業計算機上執行大規模 Windows 11 兼容性檢查。在這種情況下,您可以運行此 PowerShell 腳本並使用 SCCM、Intune 甚至 WSUS(也可以部署第三方軟件和腳本)等工具收集信息。對於簡單的情況,您可以通過組策略運行此 PowerShell 腳本,並將結果保存在 Active Directory 的計算機對象屬性中。
原來的腳本代碼需要稍微修改一下。
建議閱讀:使用 PowerShell 腳本獲取 Windows 事件日誌年齡
請注意,此 PowerShell 腳本文件的代碼已由 Microsoft 進行數字簽名。然而,簽名證書已於 2022 年到期。
編輯 HardwareReadiness.ps1 文件並在末尾、之前添加以下代碼#SIG # 簽名塊開始:
$outObject = $outObject | ConvertTo-Json -Compress
$computer = $env:COMPUTERNAME
$ComputerSearcher = New-Object DirectoryServices.DirectorySearcher
# Specify your domain name
$ComputerSearcher.SearchRoot = "LDAP://DC=WOSHUB,DC=LOC"
$ComputerSearcher.Filter = "(&(objectCategory=Computer)(CN=$Computer))"
$computerObj = [ADSI]$ComputerSearcher.FindOne().Path
$computerObj.Put( "Info", $outObject )
$computerObj.SetInfo()


此 PowerShell 代碼將 Windows 11 兼容性信息寫入資訊Active Directory 中的計算機屬性。
將 PS1 腳本文件複製到\woshub.locNetlogon域控制器上的文件夾。


打開域組策略管理控制台(gpmc.msc),創建一個新的 GPO,並將其鏈接到計算機的 OU。
導航至計算機配置 -> 策略 -> Windows 設置 -> 腳本(啟動/關閉)-> 啟動 ->選項卡PowerShell 腳本,並指定 HardwareReadiness.ps1 腳本的 UNC 路徑


轉到計算機配置 -> 管理模板 -> 系統 -> 組策略。啟用策略配置登錄腳本延遲並設置一個1分鐘腳本執行延遲。
另外,啟用在計算機啟動和登錄時始終等待網絡計算機配置 -> 管理模板 -> 系統 -> 登錄下的選項。
詳細了解如何通過 GPO 運行登錄 PowerShell 腳本。
重新啟動客戶端的計算機。啟動 ADUC 控制台(dsa.msc)並打開計算機屬性。前往屬性編輯器選項卡並檢查資訊參數現在包含檢查計算機 Windows 11 兼容性的結果。在“屬性編輯器”選項卡中,檢查資訊參數現在包含計算機的 Windows 11 兼容性檢查的結果。


在所有計算機上運行登錄腳本後,您可以使用 Get-ADComputer cmdlet 從 Active Directory 快速查看有關兼容和不兼容計算機的信息:
Get-ADComputer -Filter {enabled -eq "true"} -properties *| Where-Object {$_.info -ne $null}


有關不兼容計算機和不滿足 Win 11 最低要求的特定計算機硬件的更多詳細信息,請運行以下 PowerShell 腳本:
$Report = @()
$computers = Get-ADComputer -Filter {enabled -eq "true"} -properties *| Where-Object { $_.Info -match '"returnCode":1'}
foreach ($computer in $computers){
$jsonString =$computer.info
$object = $jsonString | ConvertFrom-Json
$returnReasonValues = $object.returnReason -split ', '
$CompInfo = [PSCustomObject]@{
"Computer" = $computer.name
"NonCompatibleItems" = $returnReasonValues
}
$Report += $CompInfo
}
$Report|fl
ConvertFrom-Json cmdlet 用於將數據從 JSON 格式轉換。


目前,您可以通過使用註冊表中的多個註冊表選項,在全新安裝 Windows 11 期間忽略對 TPM、安全啟動和其他硬件要求的檢查。實驗室配置鑰匙。並與允許升級不支持的TP或CPU關鍵是,即使在硬件不受支持的計算機上,您也可以升級到 Windows 11。
