top of page

PowerShell | Windows Update Cummulative Patch Review

#Each Month Update the Items in RED text to reflect patches you are looking to see if were installed.

$Pinged=@()

 

$All += Get-Content C:\temp\ComputerList.txt

​

$Pinged+=  $All | % {new-object psobject -Property @{Computername=$_; Reachable=(test-connection -ComputerName $_ -Quiet -Count 1)}} | Where-Object {$_.Reachable -eq "True"} | Select -ExpandProperty ComputerName -ErrorVariable A -ErrorAction SilentlyContinue                            

 

$WIN10 = @()

$WIN2012 = @()

$WIN2016 = @()

$WIN2019 = @()

$WIN2022 = @()

 

 

Foreach($Comp in $Pinged){

    $WIN10+=Get-ADComputer $Comp -Properties * | Where{$_.OperatingSystem -like "Windows 10*"} | Select -ExpandProperty Name

    $WIN2012+=Get-ADComputer $Comp -Properties * | Where{$_.OperatingSystem -like "Windows Server 2012*"} | Select -ExpandProperty Name

    $WIN2016+=Get-ADComputer $Comp -Properties * | Where{$_.OperatingSystem -like "Windows Server 2016*"} | Select -ExpandProperty Name

    $WIN2019+=Get-ADComputer $Comp -Properties * | Where{$_.OperatingSystem -like "Windows Server 2019*"} | Select -ExpandProperty Name

    $WIN2022+=Get-ADComputer $Comp -Properties * | Where{$_.OperatingSystem -like "Windows Server 2022*"} | Select -ExpandProperty Name

 

}

 

CLS

 

Write-Host "`n------------------------------------------Windows 10-------------------------------------------------------"

 

#Windows 10 KB

Invoke-Command -ComputerName $WIN10 -ScriptBlock {

 

    Get-HotFix KB5023696 -ErrorAction SilentlyContinue -ErrorVariable ScottsError

    if($ScottsError -ne ""){"Error on -$Env:Computername"}

 

}  | Tee-Object C:\temp\PCN-10.txt

 

Write-Host "`n-----------------------------------------Windows Server 2016-----------------------------------------------"

 

#WIN 2106 KB

Invoke-Command -ComputerName $WIN2016 -ScriptBlock {

 

  Get-HotFix KB5023697 -ErrorAction SilentlyContinue -ErrorVariable ScottsError

    if($ScottsError -ne ""){"Error on -$Env:Computername"}

 

}  | Tee-Object C:\temp\PCN-2016.txt

 

Write-Host "`n-----------------------------------------Windows Server 2019------------------------------------------------"

 

#WIN 2019 KB

Invoke-Command -ComputerName $WIN2019 -ScriptBlock {

 

  Get-HotFix KB5023702 -ErrorAction SilentlyContinue -ErrorVariable ScottsError

    if($ScottsError -ne ""){"Error on -$Env:Computername"}

 

 

}  | Tee-Object C:\temp\PCN-2019.txt

 

Write-Host "`n-----------------------------------------Windows Server 2022-----------------------------------------------"

 

#WIN 2022 KB

Invoke-Command -ComputerName $WIN2022 -ScriptBlock {

 

  Get-HotFix KB5023705 -ErrorAction SilentlyContinue -ErrorVariable ScottsError

    if($ScottsError -ne ""){"Error on -$Env:Computername"}

 

}  | Tee-Object C:\temp\PCN-2022.txt

bottom of page