Skip to content

Instantly share code, notes, and snippets.

@markwragg
Last active October 21, 2023 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markwragg/02f1fa9a06f823ed15ce22c7977e13a1 to your computer and use it in GitHub Desktop.
Save markwragg/02f1fa9a06f823ed15ce22c7977e13a1 to your computer and use it in GitHub Desktop.
Powershell script to check whether a hotfix is installed on multiple servers.
[CmdletBinding()]
Param(
$Computers = (Import-csv ".\servers.csv"), #Must include "adaccountname" column
$Patch = "KB2468871"
)
$i = 1
ForEach ($Server in $Computers) {
Write-Progress -Activity "Checking $Server for hotfix $Patch" -Status "$i of $($Computers.Count)" -PercentComplete (($i / $Computers.Count)*100)
If(Test-Connection -Count 1 -ComputerName $Server.adaccountname){
$hotfix = Get-HotFix -ComputerName $server.adaccountname -Id $Patch -ErrorAction 0;
If ($hotfix){$found = "Y"} Else {$found = "N"}
}
Else {$found = "ConnectFailed"}
$Server | Select *,@{Name="Patch";Expression={$found}} | Export-CSV "Hotfix-$Patch-$(get-date -format yyyy-MM-dd).csv" -NoTypeInformation -Append
$i++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment