WIndows updates and remote sessions

THIS IS NOT WORKING, i will update it ASAP

I have read a bunch of stuff about WSUS and Powershell.  Seems unnecessarily complex when i mostly want to get windows update info about one – or a few – computers.

Assuming remote sessions are enabled (and why the heck not?), you can do this, from David at http://blog.mccumber.info.  Write a local script and execute it (locally) – open a session, run the local script in the content of the remove session, get the data, exit-pssession.

enter-pssession -computername is-computer

#Get All Assigned updates in $SearchResult
$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
$SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")

#Matrix Results for type of updates that are needed
$Critical = $SearchResult.updates | where { $_.MsrcSeverity -eq "Critical" }
$important = $SearchResult.updates | where { $_.MsrcSeverity -eq "Important" }
$other = $SearchResult.updates | where { $_.MsrcSeverity -eq $null }

#Write Results
Write-Host "total=$($SearchResult.updates.count)"
Write-Host "critical=$($Critical.count)"
Write-Host "important=$($Important.count)"
Write-Host "other=$($other.count)"
# exit-pssession
write-host("there are $($important.count) updates that are important")

The last write-host is just to demonstrate that the $important variable is present in the local session.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.