Private/_GetInstalledUpdates.ps1
function _GetInstalledUpdates { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] $Identity ) begin { $ScriptBlock = { $Session = New-Object -ComObject 'Microsoft.Update.Session' $Searcher = $Session.CreateUpdateSearcher() $historyCount = $Searcher.GetTotalHistoryCount() $Searcher.QueryHistory(0, $historyCount) | Select-Object Title, Description, Date, @{name = 'Operation'; expression = { switch ($_.operation) { 1 { 'Installation' }; 2 { 'Uninstallation' }; 3 { 'Other' } } } } } } process { if ($Identity -eq $env:COMPUTERNAME) { $Output = Invoke-Command -ScriptBlock $ScriptBlock } else { $Session = New-PSSession -ComputerName $Identity -ErrorAction SilentlyContinue If (!($Session)) { Return 'Offline' } $Output = Invoke-Command -Session $Session -ScriptBlock $ScriptBlock } } end { return $Output } } |