The following script will allow you to query your available Windows Updates in Powershell and it will export it to a CSV file.
#Specify the location of where you want the CSV to be saved (Ex:\\Fileshare)
$location = "\\SHARE"
$MSsearch = New-Object -ComObject Microsoft.Update.Searcher
$Pending = $MSsearch.Search("IsInstalled=0")
$Update = $Pending.Updates
$Title = $Update | Select-Object Title | foreach { $_.Title }
$timeformat= "MM-dd"
$date = (Get-Date).ToString($timeformat)
if($Update.Count -eq 0) {
Write-Host "There are no updates available for $env:Computername"
}
else {
foreach($titles in $title){
$kb = $titles.split('(')[-1].replace(')','')
if($kb -like "kb*") {
$table = New-Object –TypeName PSObject -Property @{
'Title' = $Titles
'URL' = "https://support.microsoft.com/en-us/kb/$kb"
}
}
else {
$table = New-Object –TypeName PSObject -Property @{
'Title' = $Titles
'URL' = "Not Available"
}
}
$table | Select-Object Title, URL | Export-CSV -NoTypeInformation -Append "$location\Report.xml"
}
}
