I am trying to get a list of available updates using
$UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
Write-Host "[1]"
$UpdateSession.ClientApplicationID = 'MSDN PowerShell Sample'
Write-Host "[2]"
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
Write-Host "[3]"
$SearchResult = $UpdateSearcher.Search("IsInstalled=0 and IsHidden=0")
Write-Host "[4]"
The last instruction $SearchResult = $UpdateSearcher.Search("IsInstalled=0 and IsHidden=0") freezes, returns nothing and I can't figure out why.
Output :
[1]
[2]
[3]
<running...>
I assume it is actually doing something because I can't CTRL+C to stop it. Have to re-start Powershell.
(W7 SP1, .NET Framework 4.6.1, Powershell 4.0)
Any idea ?
Edit: took those lines from the Get-WindowsUpdates.ps1 script