Skip to content

Instantly share code, notes, and snippets.

@michaeltlombardi
Created January 11, 2016 20:55
Show Gist options
  • Save michaeltlombardi/f17229c6acaa0e79d86f to your computer and use it in GitHub Desktop.
Save michaeltlombardi/f17229c6acaa0e79d86f to your computer and use it in GitHub Desktop.
$TargetComputers = Import-Csv c:\ADcomputers.csv | Select-Object -ExpandProperty Name
ForEach($Target in $TargetComputers){
If (Test-Connection -ComputerName $Target -Count 1){
Get-Hotfix -ComputerName $Target |
Sort-Object -Property InstalledOn -Descending |
Select-Object -First 1 -Property InstalledOn,PSComputerName |
Export-Csv -Path C:\patchstatus.csv -Append
} Else {
Write-Error "Unable to connect to $Target"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment