April 26, 2024

Powershell ile uzak sunucularda Windows Update listesini çekme – Hotfix

Powershell ile uzak sunucularda Windows update listesini çekmek için aşağıdaki komutu kullanabilirsiniz.

 

Get-Content -Path “C:\Users\Administrator\Desktop\serverlist.txt” |
Where-Object {$_ -and (Test-Connection -ComputerName $_ -Quiet)} |
ForEach-Object {
$upTime = (Get-Date) – (Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $_).LastBootUpTime
Get-HotFix -ComputerName $_ |
Format-Table CSName, Description, HotFixID, InstalledBy, InstalledOn,
@{Name = ‘UpTime’; Expression = {$upTime}}
}

 

Eğer sunucuları bir txt listesinden değil de Direkt olarak AD üzerinden çekerek hotfix kontrolü yapmak isterseniz aşağıdaki komutu kullanabilirsiniz

$Computers=@(Get-ADComputer -Filter * -Properties Name | select -ExpandProperty name)

foreach ($i in $Computers){

Get-Hotfix | Select-Object -Property Description,HotFixID,Installedon, @{n=’HotFixAge’;e={(New-TimeSpan -Start $PSItem.InstalledOn).Days}},InstalledBy |Sort-Object -Descending Installedon |Format-Table
}

Bir yanıt yazın