Questo articolo descrive in dettaglio la procedura per verificare quali dispositivi Windows 10 sono idonei per un aggiornamento a Windows 11 e avviare automaticamente tale aggiornamento utilizzando i criteri FleetDM e gli script di PowerShell .
La procedura comprende:
- Rilevamento e memorizzazione dei componenti di sistema richiesti (TPM 2.0 e Secure Boot) nel registro
- Convalida dei requisiti hardware e software per determinare l'idoneità all'aggiornamento
- Esecuzione di un download automatico e di un'installazione silenziosa di Windows 11 su dispositivi compatibili
Classificare i dispositivi con TPM e Secure Boot presenti
Creare la policy di rilevamento (registro FleetDM)
Utilizzare la seguente query per verificare la presenza di chiavi di registro che memorizzeranno lo stato TPM e Secure Boot :
SELECT 1 WHERE EXISTS ( SELECT 1 FROM registry WHERE path = 'HKEY_LOCAL_MACHINE\Software\FleetDM\TPMVersion' ) AND EXISTS ( SELECT 1 FROM registry WHERE path = 'HKEY_LOCAL_MACHINE\Software\FleetDM\SecureBoot' );Eseguire lo script associato (popolare il registro)
Associa questo script di PowerShell al criterio sopra indicato. Rileva la versione del TPM e lo stato di Secure Boot, quindi li scrive nel registro di Windows per FleetDM.
$TPM = Get-WmiObject -Namespace "Root\CIMv2\Security\MicrosoftTpm" -Class Win32_Tpm$SecureBoot = Confirm-SecureBootUEFI$TPMVersion = $TPM.SpecVersion$SecureBootEnabled = if ($SecureBoot) { 1 } else { 0 }# Write values to the registry (example)New-Item -Path "HKLM:\Software\FleetDM" -Force | Out-NullSet-ItemProperty -Path "HKLM:\Software\FleetDM" -Name "TPMVersion" -Value $TPMVersionSet-ItemProperty -Path "HKLM:\Software\FleetDM" -Name "SecureBoot" -Value $SecureBootEnabledRisultato previsto: HKLM\Software\FleetDM\TPMVersion e HKLM\Software\FleetDM\SecureBoot vengono creati/aggiornati.
Valutare l'idoneità di un dispositivo Windows 10 per Windows 11
Creare il seguente criterio per convalidare i requisiti minimi (RAM, core CPU, architettura, TPM 2.0, avvio protetto) ed escludere i dispositivi non conformi.
SELECT 1 FROM os_version as os JOIN system_info as si WHERE os.name NOT LIKE 'Microsoft Windows 10%' OR si.physical_memory < 4 * 1024 * 1024 * 1024 OR si.cpu_physical_cores < 2 OR si.cpu_type NOT LIKE '%x86_64%' OR NOT EXISTS ( SELECT * FROM registry WHERE path = 'HKEY_LOCAL_MACHINE\Software\FleetDM\TPMVersion' AND data LIKE '2%' ) OR NOT EXISTS ( SELECT * FROM registry WHERE path = 'HKEY_LOCAL_MACHINE\Software\FleetDM\SecureBoot' AND data = '1' );Interpretazione: la query restituisce 1 se il dispositivo non è un Windows 10 conforme. Utilizzarlo come criterio di non conformità per mantenere solo i dispositivi idonei (quelli per i quali la query non restituisce 1).
Attiva l'aggiornamento a Windows 11 (dispositivi idonei)
Allegare lo script di distribuzione seguente ai dispositivi compatibili. Scarica l'ISO di Windows 11, monta l'immagine, copia le sorgenti localmente e pianifica un'installazione invisibile all'utente in SYSTEM .
# ImportsImport-Module BitsTransfer# Variables$uri = "https://production-bucket-public-files.s3.eu-west-3.amazonaws.com/Win11_24H2_French_x64.iso"$destination = "C:\Win11.iso"$log = "C:\logs\download_win11_iso.log"# Create the logs folder if it doesn't existif (-not (Test-Path -Path "C:\logs")) { New-Item -Path "C:\logs" -ItemType Directory | Out-Null}# Start the downloadtry { "`n[$(Get-Date)] Starting download..." | Out-File -Append $log if (-not (Test-Path $destination)){ Start-BitsTransfer -Source $uri -Destination $destination } "`n[$(Get-Date)] Download completed successfully." | Out-File -Append $log} catch { "`n[$(Get-Date)] Error during download: $_" | Out-File -Append $log}# Additional variables$isoPath = "C:\Win11.iso"$setupFolder = "C:\Temp\Win11Files"$taskName = "Win11SilentUpgrade"# Step 1 - Mount the ISOMount-DiskImage -ImagePath $isoPath -PassThru | Out-NullStart-Sleep -Seconds 2$vol = Get-Volume -DiskImage (Get-DiskImage -ImagePath $isoPath)$driveLetter = $vol.DriveLetter# Step 2 - Copy ISO content locallyNew-Item -ItemType Directory -Force -Path $setupFolder | Out-NullCopy-Item "$driveLetter`:\*" -Destination $setupFolder -Recurse# Unmount the ISODismount-DiskImage -ImagePath $isoPath# Step 3 - Create and schedule the installation task$action = New-ScheduledTaskAction -Execute "C:\Temp\Win11Files\setup.exe" -Argument "/auto upgrade /migratedrivers none /resizerecoverypartition enable /dynamicupdate disable /eula accept /quiet /noreboot /uninstall disable /compat ignorewarning /copylogs C:\logs\WinSetup.log"$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest$task = New-ScheduledTask -Action $action -Principal $principal -Trigger (New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1))Register-ScheduledTask -TaskName $taskName -InputObject $task -Force# Step 4 - Start the task immediatelyStart-ScheduledTask -TaskName $taskName