Mantenere Windows 11 aggiornato è fondamentale per la sicurezza e le prestazioni. Sebbene sia possibile controllare manualmente la cronologia di Windows Update, l'utilizzo di uno script PowerShell offre un modo più rapido e dettagliato per visualizzare lo stato degli aggiornamenti del sistema. Questo articolo ti mostrerà come utilizzare uno script PowerShell per verificare le informazioni attuali sulla patch di Windows 11 e gli aggiornamenti disponibili.
Lo script PowerShell che utilizzeremo fornisce informazioni complete sull'installazione di Windows 11, tra cui:
- Versione attuale del sistema operativo
- Modifica del sistema operativo
- Numero di build del sistema operativo
- Ultimo aggiornamento installato (con numero KB e collegamento informativo)
- Aggiornamento disponibile più recente
Questo script funziona sia per i sistemi Windows 11 che per Windows 10. Vediamo come usarlo.
Passaggio 1:Apri PowerShell come amministratore. Fare clic con il pulsante destro del mouse sul pulsante Start e selezionare "Windows PowerShell (Admin)" dal menu.
Passaggio 2:Copia il seguente script di PowerShell e salvalo come file .ps1 (ad esempio, "Get-WindowsUpdateInfo.ps1") sul desktop:
[CmdletBinding()]
Param(
[switch]$ListAllAvailable,
[switch]$ExcludePreview,
[switch]$ExcludeOutofBand
)
$ProgressPreference="SilentlyContinue"
$URI = "https://aka.ms/WindowsUpdateHistory"
Function Get-MyWindowsVersion {
[CmdletBinding()]
Param
(
$ComputerName = $env:COMPUTERNAME
)
$Table = New-Object System.Data.DataTable
$Table.Columns.AddRange(@("ComputerName","Windows Edition","Version","OS Build"))
$ProductName = (Get-ItemProperty 'HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion' -Name ProductName).ProductName
Try
{
$Version = (Get-ItemProperty 'HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion' -Name ReleaseID -ErrorAction Stop).ReleaseID
}
Catch
{
$Version = "N/A"
}
$CurrentBuild = (Get-ItemProperty 'HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion' -Name CurrentBuild).CurrentBuild
$UBR = (Get-ItemProperty 'HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion' -Name UBR).UBR
$OSVersion = $CurrentBuild + "." + $UBR
$TempTable = New-Object System.Data.DataTable
$TempTable.Columns.AddRange(@("ComputerName","Windows Edition","Version","OS Build"))
[void]$TempTable.Rows.Add($env:COMPUTERNAME,$ProductName,$Version,$OSVersion)
Return $TempTable
}
Function Convert-ParsedArray {
Param($Array)
$ArrayList = New-Object System.Collections.ArrayList
foreach ($item in $Array)
{
[void]$ArrayList.Add([PSCustomObject]@{
Update = $item.outerHTML.Split('>')[1].Replace('</a','').Replace('—',' - ')
KB = "KB" + $item.href.Split('/')[-1]
InfoURL = "https://support.microsoft.com" + $item.href
OSBuild = $item.outerHTML.Split('(OS ')[1].Split()[1]
})
}
Return $ArrayList
}
If ($PSVersionTable.PSVersion.Major -ge 6)
{
$Response = Invoke-WebRequest -Uri $URI -ErrorAction Stop
}
else
{
$Response = Invoke-WebRequest -Uri $URI -UseBasicParsing -ErrorAction Stop
}
If (!($Response.Links))
{ throw "Response was not parsed as HTML"}
$VersionDataRaw = $Response.Links | where {$_.outerHTML -match "supLeftNavLink" -and $_.outerHTML -match "KB"}
$CurrentWindowsVersion = Get-MyWindowsVersion -ErrorAction Stop
If ($ListAllAvailable)
{
If ($ExcludePreview -and $ExcludeOutofBand)
{
$AllAvailable = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.') -and $_.outerHTML -notmatch "Preview" -and $_.outerHTML -notmatch "Out-of-band"}
}
ElseIf ($ExcludePreview)
{
$AllAvailable = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.') -and $_.outerHTML -notmatch "Preview"}
}
ElseIf ($ExcludeOutofBand)
{
$AllAvailable = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.') -and $_.outerHTML -notmatch "Out-of-band"}
}
Else
{
$AllAvailable = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')}
}
$UniqueList = (Convert-ParsedArray -Array $AllAvailable) | Sort OSBuild -Descending -Unique
$Table = New-Object System.Data.DataTable
[void]$Table.Columns.AddRange(@('Update','KB','InfoURL'))
foreach ($Update in $UniqueList)
{
[void]$Table.Rows.Add(
$Update.Update,
$Update.KB,
$Update.InfoURL
)
}
Return $Table
}
$CurrentPatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'} | Select -First 1
If ($ExcludePreview -and $ExcludeOutofBand)
{
$LatestAvailablePatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.') -and $_.outerHTML -notmatch "Out-of-band" -and $_.outerHTML -notmatch "Preview"} | Select -First 1
}
ElseIf ($ExcludePreview)
{
$LatestAvailablePatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.') -and $_.outerHTML -notmatch "Preview"} | Select -First 1
}
ElseIf ($ExcludeOutofBand)
{
$LatestAvailablePatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.') -and $_.outerHTML -notmatch "Out-of-band"} | Select -First 1
}
Else
{
$LatestAvailablePatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')} | Select -First 1
}
$Table = New-Object System.Data.DataTable
[void]$Table.Columns.AddRange(@('OSVersion','OSEdition','OSBuild','CurrentInstalledUpdate','CurrentInstalledUpdateKB','CurrentInstalledUpdateInfoURL','LatestAvailableUpdate','LastestAvailableUpdateKB','LastestAvailableUpdateInfoURL'))
[void]$Table.Rows.Add(
$CurrentWindowsVersion.Version,
$CurrentWindowsVersion.'Windows Edition',
$CurrentWindowsVersion.'OS Build',
$CurrentPatch.outerHTML.Split('>')[1].Replace('</a','').Replace('—',' - '),
"KB" + $CurrentPatch.href.Split('/')[-1],
"https://support.microsoft.com" + $CurrentPatch.href,
$LatestAvailablePatch.outerHTML.Split('>')[1].Replace('</a','').Replace('—',' - '),
"KB" + $LatestAvailablePatch.href.Split('/')[-1],
"https://support.microsoft.com" + $LatestAvailablePatch.href
)
Return $Table
Passaggio 3:Esegui lo script immettendo il seguente comando in PowerShell:
.Get-WindowsUpdateInfo.ps1
Questo comando visualizzerà la versione corrente di Windows, il numero di build e l'ultimo aggiornamento installato.
Passaggio 4:Per escludere gli aggiornamenti di anteprima e fuori banda dai risultati, utilizzare questo comando:
Vedi anche:Ottieni lo stato MFA in Microsoft Entra e PowerShell
.Get-WindowsUpdateInfo.ps1 -ExcludePreview -ExcludeOutofBand
Questa opzione è utile se vuoi concentrarti solo sugli aggiornamenti cumulativi standard.
Passaggio 5:Per visualizzare tutti gli aggiornamenti disponibili per la tua versione di Windows, utilizza il seguente comando:
.Get-WindowsUpdateInfo.ps1 -ListAllAvailable
Questo ti mostrerà un elenco di tutti gli aggiornamenti che Microsoft ha pubblicato per la tua specifica versione di Windows.
Passaggio 6:Se desideri visualizzare tutti gli aggiornamenti disponibili ad eccezione dell'anteprima e degli aggiornamenti fuori banda, utilizza questo comando:
.Get-WindowsUpdateInfo.ps1 -ListAllAvailable -ExcludePreview -ExcludeOutofBand
Questo comando combina le opzioni per fornirti un elenco mirato di aggiornamenti standard.
L'uso di questo script PowerShell semplifica il processo di controllo dello stato dell'aggiornamento di Windows 11. È particolarmente utile per i professionisti IT che gestiscono più sistemi o per gli utenti che desiderano informazioni dettagliate sugli aggiornamenti di Windows senza dover navigare tra più menu.







![Come ottenere Gemini Ai Pro gratuiti per un valore di £ 19.500 per un anno [Guida]](https://elsefix.com/tech/afton/wp-content/uploads/cache/2025/08/Gemini-AI-Pro-free-studentsjpg.jpg)






