Pages

6/09/2011

POWERSHELL List Updates in WSUS

[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer('WSUS02',$False,80)
#Get all updates
$updates = $wsus.GetUpdates()
#Iterate every update and output some basic info about it
$collection = @()
ForEach ($update in $updates) {
#$update
$product = $update.ProductTitles
$product.type
 $obj = New-Object System.Object
 $obj | Add-Member -type NoteProperty -name Date -value $update.CreationDate.ToString()
 $obj | Add-Member -type NoteProperty -name Approved -value $update.IsApproved.ToString()
 $obj | Add-Member -type NoteProperty -name Class -value $update.UpdateClassificationTitle
 $obj | Add-Member -type NoteProperty -name Product -value $product
 $obj | Add-Member -type NoteProperty -name Title -value $update.Title
 $collection += $obj 
}#ForEach

$collection | Sort-Object Date | export-csv .\updates.csv -force

No comments: