@MotoX80
PowerShell transcript start
Start time: 20240919175116
Username: WINDOWS-11\Piero
RunAs User: WINDOWS-11\Piero
Configuration Name:
Machine: WINDOWS-11 (Microsoft Windows NT 10.0.22631.0)
Host Application: C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.5.0_x64__8wekyb3d8bbwe\pwsh.dll
Process ID: 11232
PSVersion: 7.4.5
PSEdition: Core
GitCommitId: 7.4.5
OS: Microsoft Windows 10.0.22631
Platform: Win32NT
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
WSManStackVersion: 3.0
Transcript started, output file is C:\windows\temp\KB-Test.log
PS C:\Windows\System32> $Res = 0
PS C:\Windows\System32> $look4 = 'KB5030310'
PS C:\Windows\System32> $UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
PS C:\Windows\System32> $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
PS C:\Windows\System32> $count = $UpdateSearcher.GetTotalHistoryCount()
PS C:\Windows\System32> Write-Host "We found $count total updates."
We found 167 total updates.
PS C:\Windows\System32> if ($Count -ge 1) {
$Updates = $UpdateSearcher.QueryHistory(0,$count)
Write-Host "QueryHistory returned $($updates.count) updates."
$kb = $Updates | Where-Object {$_.Title -match $look4}
if ($kb -eq $null) {
Write-Host "We did not find $look4."
} else {
Write-Host "We found $look4."
$Res = 1
}
```}
QueryHistory returned 167 updates.
We did not find KB5030310.
PS C:\Windows\System32> Write-Host 'Final result:',$res
Final result: 0
PS C:\Windows\System32> Stop-Transcript
**********************
PowerShell transcript end
End time: 20240919175212
**********************