Last active
October 21, 2023 08:24
-
-
Save markwragg/02f1fa9a06f823ed15ce22c7977e13a1 to your computer and use it in GitHub Desktop.
Powershell script to check whether a hotfix is installed on multiple servers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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