업데이트를 제거하는 powershell 스크립트를 작성하려고합니다.wusa.exe를 사용하여 업데이트 제거
내 문제는 스크립트가 시작될 때 wusa.exe
스크립트가 실행되지 않는다는 것입니다.
function Uninstall-Hotfix() {
[string]$parameters = "KB4041691"
[string]$KBs = @()
if ($parameters.Contains(":")) {
[object]$arguments = $parameters.Split(":")
foreach ($argument in $arguments) {
$argument.Replace("KB", "")
$KBs.add($argument)
for ($i = 0; $i -lt $KBs.length; $i++) {
Cmd /c wusa.exe /uninstall /KB:$KBs[$i] /quiet /norestart
Do {
Start-Sleep -Seconds 3
}
while (Wait-Process | Where-Object {$_.name -eq "wusa"})
If (Get-Hotfix -Id $KBs[$i] -ErrorAction SilentlyContinue) {
Write-Host "KB $KBs[$i] Fehlerhaft"
}
Else {
Write-Host "KB $KBs[$i] Erfolgreich deinstalliert"
}
}
}
}
Else {
$parameter = $parameters.Replace("KB", "")
$parameter
cmd /c wusa.exe /uninstall /KB:$parameter /quiet /norestart
Do {
Start-Sleep -Seconds 3
}
while (Wait-Process | Where-Object {$_.name -eq "wusa.exe"})
}
}
Uninstall-Hotfix
cmd를 명령하지 않은 오류 메시지를 참조하십시오. 시작 프로세스를 사용하거나 wusa.exe를 직접 호출하십시오. – guiwhatsthat
시도해보십시오. & wusa.exe/uninstall/KB : $ parameter/quiet/norestart' –
@guiwhatsthat : Powershell은 오류를 표시하지 않고 "cmd"명령을 사용하여 다른 스크립트를 보았습니다. – MRed