PowerShell ile Windows 11 Güncelleme Durumu Nasıl Kontrol Edilir

Windows 11'i güncel tutmak güvenlik ve performans açısından çok önemlidir. Windows Güncelleme Geçmişini manuel olarak kontrol edebilseniz de PowerShell betiği kullanmak, sisteminizin güncelleme durumunu görüntülemenin daha hızlı ve daha ayrıntılı bir yolunu sunar. Bu makale, mevcut Windows 11 yama bilgilerinizi ve mevcut güncellemeleri kontrol etmek için PowerShell betiğini nasıl kullanacağınızı gösterecektir.

Kullanacağımız PowerShell betiği, Windows 11 kurulumunuz hakkında aşağıdakiler dahil kapsamlı bilgiler sağlar:

  • Mevcut işletim sistemi sürümü
  • İşletim sistemi sürümü
  • İşletim sistemi yapı numarası
  • En son yüklenen güncelleme (KB numarası ve bilgi bağlantısıyla birlikte)
  • Mevcut en son güncelleme

Bu komut dosyası hem Windows 11 hem de Windows 10 sistemlerinde çalışır. Nasıl kullanılacağını inceleyelim.

Adım 1:PowerShell'i yönetici olarak açın. Başlat düğmesine sağ tıklayın ve menüden “Windows PowerShell (Yönetici)” seçeneğini seçin.

Adım 2:Aşağıdaki PowerShell betiğini kopyalayın ve masaüstünüze bir .ps1 dosyası (ör. "Get-WindowsUpdateInfo.ps1") olarak kaydedin:

[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

3. Adım:PowerShell'e aşağıdaki komutu girerek betiği çalıştırın:

.Get-WindowsUpdateInfo.ps1

Bu komut mevcut Windows sürümünüzü, yapı numaranızı ve en son yüklü güncellemeyi gösterecektir.

4. Adım:Önizleme ve bant dışı güncellemeleri sonuçların dışında bırakmak için bu komutu kullanın:

.Get-WindowsUpdateInfo.ps1 -ExcludePreview -ExcludeOutofBand

Yalnızca standart toplu güncellemelere odaklanmak istiyorsanız bu seçenek kullanışlıdır.

Adım 5:Windows sürümünüze ilişkin mevcut tüm güncellemeleri görüntülemek için aşağıdaki komutu kullanın:

.Get-WindowsUpdateInfo.ps1 -ListAllAvailable

Bu size Microsoft'un belirli Windows sürümünüz için yayınladığı tüm güncellemelerin bir listesini gösterecektir.

Adım 6:Önizleme ve bant dışı güncellemeler dışında mevcut tüm güncellemeleri görmek istiyorsanız bu komutu kullanın:

.Get-WindowsUpdateInfo.ps1 -ListAllAvailable -ExcludePreview -ExcludeOutofBand

Daha fazla okuma:PowerShell ile Ekipler Kullanıcı Durumunu Sorgulama ve Değiştirme

Bu komut, size odaklanmış bir standart güncelleme listesi sunmak için seçenekleri birleştirir.

Bu PowerShell betiğini kullanmak, Windows 11 güncelleme durumunuzu kontrol etme işlemini basitleştirir. Birden fazla sistemi yöneten BT profesyonelleri veya birden fazla menüde gezinmeden Windows güncellemeleri hakkında ayrıntılı bilgi isteyen kullanıcılar için özellikle yararlıdır.

Related Posts