Now days everybody talking about patch vulnerability in the organization
and admin has to take care there job very seriously .Every users machine need
to fully patch with security patches and sometime admin need to check some critical patches are installed on the users
machine or not.
This small logic will help you to get info from users machines
for particular KB is installed or not.
You just has to pass machine name C:\temp\PCNameList.txt.
####################### Get All Patch Installed On Remote Machine ##################
$ServerName = Get-Content "C:\temp\PCNameList.txt"
foreach ($Server in $ServerName)
{
if (test-Connection -ComputerName $Server -Count 2 -Quiet )
{
"$Server is Pinging"
Get-hotfix -computername $server | select-object -property Description,HotFixID,InstalledBy,InstalledOn | export-csv c:\temp\$server.csv
}
Else
{
"$Server not pinging"
}
}
################################################################################
###################Get single Patch Installed On Remote Machine####################
$ServerName = Get-Content "C:\temp\PCNameList.txt"
foreach ($Server in $ServerName)
{
if (test-Connection -ComputerName $Server -Count 2 -Quiet )
{
"$Server is Pinging"
Get-hotfix -computername $server | select-object -property Description,HotFixID,InstalledBy,InstalledOn | where {$_.hotfixid -match 'KB4012212'} | export-csv c:\temp\$server.csv
}
Else
{
"$Server not pinging"
}
}
Note:- Please test script in your test environment before running in production directly.
No comments:
Post a Comment