Jose Rivera-Hernandez
asked on
Remove KB with script - problem running script
I am running this script that I found here, but it is giving me this error. The script is vbs, should it be different? I am trying to run it in a Terminal server 2012 to remove a KB in multiple computers.
function Uninstall-Hotfix {
[cmdletbinding()]
param(
$computername = $env:computername,
[string] $HotfixID
)
$hotfixes = Get-WmiObject -ComputerName $computername -Class Win32_QuickFixEngineering | select hotfixid
if($hotfixes -match $hotfixID) {
$hotfixID = $HotfixID.Replace("KB","31 72605")
Write-host "Found the hotfix KB" + $HotfixID
Write-Host "Uninstalling the hotfix"
$UninstallString = "cmd.exe /c wusa.exe /uninstall /KB:$hotfixID /quiet /norestart"
([WMICLASS]"\\$computernam e\ROOT\CIM V2:win32_p rocess").C reate($Uni nstallStri ng) | out-null
while (@(Get-Process wusa -computername $computername -ErrorAction SilentlyContinue).Count -ne 0) {
Start-Sleep 3
Write-Host "Waiting for update removal to finish ..."
}
write-host "Completed the uninstallation of $hotfixID"
}
else {
write-host "Given hotfix($hotfixID) not found"
return
}
}
$myComputers = Get-Content "C:\Users\jrhernandez\Desk top\comput ers.txt"
foreach ($computer in $myComputers) {
Uninstall-HotFix -ComputerName $myComputers -HotfixID KB3172605
}
function Uninstall-Hotfix {
[cmdletbinding()]
param(
$computername = $env:computername,
[string] $HotfixID
)
$hotfixes = Get-WmiObject -ComputerName $computername -Class Win32_QuickFixEngineering | select hotfixid
if($hotfixes -match $hotfixID) {
$hotfixID = $HotfixID.Replace("KB","31
Write-host "Found the hotfix KB" + $HotfixID
Write-Host "Uninstalling the hotfix"
$UninstallString = "cmd.exe /c wusa.exe /uninstall /KB:$hotfixID /quiet /norestart"
([WMICLASS]"\\$computernam
while (@(Get-Process wusa -computername $computername -ErrorAction SilentlyContinue).Count -ne 0) {
Start-Sleep 3
Write-Host "Waiting for update removal to finish ..."
}
write-host "Completed the uninstallation of $hotfixID"
}
else {
write-host "Given hotfix($hotfixID) not found"
return
}
}
$myComputers = Get-Content "C:\Users\jrhernandez\Desk
foreach ($computer in $myComputers) {
Uninstall-HotFix -ComputerName $myComputers -HotfixID KB3172605
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks!