Posted On February 9, 2022

PowerShell: Check Windows Computers for Specific KB’s

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> PowerShell: Check Windows Computers for Specific KB’s
# Check for specific KBs
$kbs='KB5010790','KB5010419'
$computernames=@('WINDOWS001','WINDOWS002')
$regexIP = [regex] "\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
$names=foreach($computername in $computernames){
    if($computername -match $regexIp){[System.Net.Dns]::GetHostByAddress($computername).hostname}else{$computername}
}
invoke-command -scriptblock {
    param($kbs)
    $result=get-hotfix|?{$_.HotFixID -in $kbs}
    if($result){
        [hashtable]@{$env:computername="Passed: $($result.HotFixID -join ',')"}
    }else{
        [hashtable]@{$env:computername='Failed'}
    }
} -Args @(,$kbs) -computername $names 

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Installing a Program from Its Zip Archive

# installProgramFromExeZipArchive.ps1 # Automated installation of the racadm program $computerlist=@' HyperV01 HyperV02 '@ $fileURL="https://dl.dell.com/FOLDER08543783M/1/DellEMC-iDRACTools-Web-WINX64-10.3.0.0-4945.exe" $expectedExecutable='racadm.exe'…

PowerShell: Check TCP Connections of Server by Port Numbers

# Check-TCP-Connections.ps1# This function will output progress onto the console as well as returning a…

Reset Windows Update Tool

:: ==================================================================================:: Re-posting this here because I admire the good work by Sir Manuel Gil::…