Checking Windows Updates Remotely

by Oct 3, 2011

In a previous tip you learned how to list installed Windows Updates. Unfortunately, this only works for local machines. Provided you have enabled PowerShell Remoting in your infrastructure, here is a sample that enables you to retrieve the information remotely:

function Get-SoftwareUpdate {

  $code = {
    $Session = New-Object -ComObject Microsoft.Update.Session
    $Searcher = $Session.CreateUpdateSearcher()
    $HistoryCount = $Searcher.GetTotalHistoryCount()
    $Searcher.QueryHistory(1,$HistoryCount) | 
      Select-Object Date, Title, Description

  $pcname = @{
    Name = 'Machine'
    Expression = { $_.PSComputerName }

  Invoke-Command $code @psboundparameters | 
    Select-Object $pcname, Date, Title, Description

Twitter This Tip!
ReTweet this Tip!