Qoraalka PowerShell si loo hubiyo heerka Cusbooneysiinta Windows

Caadi ahaan, isticmaalayaasha raba inay ogaadaan in cusboonaysiinta isugeynta ugu dambeysay lagu rakibay iyaga Windows 10 nadaamka isticmaal habkan si ay u hubiyaan Windows 10 Taariikhda Cusbooneysii . Maqaalkan, waxaan ku tusi doonaa sida loo helo macluumaadka balastarka ee hadda Windows 10 iyadoo la adeegsanayo qoraalka PowerShell.(how to get current patch information for Windows 10 using a PowerShell script.)

Qoraalka PowerShell si loo hubiyo heerka Cusbooneysiinta Windows

Qoraalka PowerShell(PowerShell) si loo hubiyo heerka Cusbooneysiinta Windows(Windows Update)

Qoraalka PowerShell waxaa loo isticmaali karaa in lagu soo sheego OS-ku dhisto Windows 10 kumbiyuutarku hadda shidnaa iyo sidoo kale cusboonaysiinta ugu dambeysay ee uu heli karo aaladda. Waxa kale oo ay ka warbixin kartaa dhammaan cusboonaysiinta Windows ee loo daabacay nooca Windows 10 goobta shaqadu hadda waa shidan tahay.

Markaad socodsiiso qoraalka, macluumaadka soo socda ayaa la soo bandhigi doonaa:

  • Nooca OS ee hadda
  • Daabacaadda OS hadda
  • Nambarka Dhismaha OS hadda
  • Cusboonaysiinta la rakibay ee u dhiganta nambarkaas dhismaha, iyo sidoo kale lambarka KB iyo xiriirka bogga macluumaadka
  • Cusboonaysiinta ugu dambeysay ee la heli karo nooca OS

Si aad u hesho Windows 10 macluumaadka balastarka hadda adoo isticmaalaya qoraalka PowerShell , waxaad u baahan tahay inaad (PowerShell)abuurto oo aad socodsiiso qoraalka PowerShell(create and run the PowerShell script) adoo isticmaalaya koodka hoose ee Github .

[CmdletBinding()]
Param(
[switch]$ListAllAvailable,
[switch]$ExcludePreview,
[switch]$ExcludeOutofBand
)
$ProgressPreference = 'SilentlyContinue'
$URI = "https://aka.ms/WindowsUpdateHistory" # Windows 10 release history

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:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ProductName).ProductName
Try
{
$Version = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID -ErrorAction Stop).ReleaseID
}
Catch
{
$Version = "N/A"
}
$CurrentBuild = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name CurrentBuild).CurrentBuild
$UBR = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -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] # Just for sorting
})
}
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('.')[0] -and $_.outerHTML -notmatch "Preview" -and $_.outerHTML -notmatch "Out-of-band"}
}
ElseIf ($ExcludePreview)
{
$AllAvailable = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')[0] -and $_.outerHTML -notmatch "Preview"}
}
ElseIf ($ExcludeOutofBand)
{
$AllAvailable = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')[0] -and $_.outerHTML -notmatch "Out-of-band"}
}
Else
{
$AllAvailable = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')[0]}
}
$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('.')[0] -and $_.outerHTML -notmatch "Out-of-band" -and $_.outerHTML -notmatch "Preview"} | Select -First 1
}
ElseIf ($ExcludePreview)
{
$LatestAvailablePatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')[0] -and $_.outerHTML -notmatch "Preview"} | Select -First 1
}
ElseIf ($ExcludeOutofBand)
{
$LatestAvailablePatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')[0] -and $_.outerHTML -notmatch "Out-of-band"} | Select -First 1
}
Else
{
$LatestAvailablePatch = $VersionDataRaw | where {$_.outerHTML -match $CurrentWindowsVersion.'OS Build'.Split('.')[0]} | 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

Waxaad ka saari kartaa Dib-u- eegis(Preview) ama Cusbooneysiin ka baxsan band-ka oo(Out-of-band) la heli karo kuwaas oo ka sii dambeeyay kii aad ku rakibtay in lagu soo sheego cusboonaysiintii ugu dambeysay ee la heli karo, marka waxaad diiradda saari kartaa cusbooneysiinta isugeynta adiga oo socodsiinaya amarka hoose:

Get-CurrentPatchInfo -ExcludePreview -ExcludeOutofBand

Waxa kale oo aad ku qori kartaa dhammaan cusboonaysiinta Windows ee (Windows)Microsoft u daabacday nooca OS kaaga amarka soo socda:

Get-CurrentPatchInfo -ListAvailable

Haddii aad rabto in aad liiska ka saarto Horu(Preview) -u-eegga iyo ka-baxsanaanta band-(Out-of-band) ka laakiin tax dhammaan cusboonaysiinta Windows ee (Windows)Microsoft u daabacday nooca OS-kaaga, socodsii amarka hoose:

Get-CurrentPatchInfo -ListAvailable -ExcludePreview -ExcludeOutofBand

Waa kaas!

Akhri soo socda(Read next) : Goobta Browser Module PowerShell waxay(PowerShell Module Browser site) kuu ogolaanaysaa inaad raadiso cmdlets & xirmooyinka.



About the author

Waxaan ahay injineer software iyo sahamiye. Waxaan khibrad u leeyahay labada Microsoft Xbox 360 iyo Google Explorer. Waxaan awoodaa inaan bixiyo talooyinka khabiirada ee qalabyada horumarinta software-ka qaarkood, iyo sidoo kale inaan caawiyo dadka inay cilad-saaraan khaladaadka Explorer ee caadiga ah.



Related posts