Thursday, April 9, 2015

windows patching date for bulk servers

1. Generate a Report for installed Hotfix-Update-ServicePack for Bulk Servers.
2. Check a specific Hotfix is installed or not in Multiple Computers.
3. Get the latest Patching Date for bulk Computers.

Create computers.txt on C drive with below command. (create servers list, remove spaces if any exist at the end of computer names, copy to excel and past back in txt)
Get-ADComputer -Filter 'OperatingSystem -like "*Server*"' -Properties * |
Select-Object Name | Sort-Object Name > c:\computers.txt

Save below script as .ps1 and execute on DC.
function Hotfixreport { 
$computers = Get-Content C:\computers.txt   
$ErrorActionPreference = 'Stop'   
ForEach ($computer in $computers) {  
Get-HotFix -cn $computer | Select-Object PSComputerName,HotFixID,Description,InstalledBy,InstalledOn | FT -AutoSize 
Write-Warning "System Not reachable:$computer" 
Hotfixreport > "$env:USERPROFILE\Desktop\Hotfixreport.txt"