Skip to content

Instantly share code, notes, and snippets.

@mrknmc
mrknmc / wsus-update.ps1
Last active August 29, 2016 04:21 — forked from jacobludriks/wsus-update.ps1
wsus-update
Function WSUSUpdate {
$LogFile = "UpdateLogs\" + (Get-Date -format yyyy-MM-dd--HH-mm) + ".log"
Start-transcript $LogFile
$Criteria = "IsInstalled=0 and Type='Software'"
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
try {
$SearchResult = $Searcher.Search($Criteria)
[Object[]] $Critical = $SearchResult.updates | where { $_.MsrcSeverity -eq "Critical" }
[Object[]] $Important = $SearchResult.updates | where { $_.MsrcSeverity -eq "Important" }
[Object[]] $Moderate = $SearchResult.updates | where { $_.MsrcSeverity -eq "Moderate" }