magritton
9/4/2016 - 5:18 AM

Powershell script to check for Updates

Powershell script to check for Updates

#This part runs on a server with SharePoint already installed
Start-Transcript C:\temp\TransGetUpdates.txt
$Criteria = "IsInstalled=1"
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
$SearchResults = $Searcher.Search($Criteria).Updates
$updateString = ""
foreach($SearchResult in $SearchResults)
{
    if($SearchResult.Title -like "*Share*")
    {
        Write-Host "SharePoint update found" -BackgroundColor Green -ForegroundColor DarkBlue
        $SearchResult.Title
        $SearchResult.Identity.UpdateID
        $SearchResult.Identity.RevisionNumber
        $updateString += '"' + $SearchResult.Identity.UpdateID + '",'
        #
    }
}
$updateString | out-file C:\temp\updatestring.txt
write-host "Done" -BackgroundColor Magenta -ForegroundColor Yellow
Stop-Transcript