Category Archives: hotfix

Removing patches or hotfixes from windows server remotely

Below is the powershell script you can use to remove patches/hotfixes from servers remotely :

if($args[0] -eq $null)
{
$servernamefile = “c:\serverlist.txt”;
$hotfixidfile= “c:\hotfixlist.txt”;
}
else
{
$servernamefile = $args[0];
$hotfixidfile = $args[1];
}

$info1 = get-content $servernamefile;
$info2 = get-content $hotfixidfile;

foreach ($hotfixid in $info2)
{

foreach ($computername in $info1)
{
$KBhotfix=”KB”+$hotfixid;
if ((get-hotfix -id $KBhotfix -computername $computername))
{
Write-Host $hotfixid ‘ found on’ $computername ‘, removing it……’;
wmic /node:$computername process call create “powershell wusa /uninstall /kb:$hotfixid /quiet /forcerestart”;
}

else
{
Write-Host $hotfixid ‘ not found on’ $computername ‘.’;
}
}

Start-Sleep -s 600;
}

Advertisements