我正在尝试写一个小脚本来删除所有安装在Win 10机器上的修补程序。由于我没有找到能够做到这一点的模块,所以我使用了Start-Process wusa.exe -ArgumentList
虽然文本文件确实只包含ArgumentList中的变量所需的纯数字(否则它将是KBKB1234565),但是什么也不会发生。
我不确定如何看到wusa实际做了什么,所以我被一些不起作用的东西卡住了,但我不知道为什么。
Powershell 5.1.16299.98,本地AdminAccount上的ExecutionPolicy未签名,提升的外壳。
#get ONLY the KB number and write in file
$KB = Get-Hotfix | Select HotfixID
$KB -replace ".*B" -replace "}" | Out-File c:\temp\temp.txt -append
$KB = Get-Content "C:\temp\temp.txt"
#remove all KBs in said file
ForEach ($Hotfix in $KB)
{
Write-Host "Uninstalling KB$Hotfix"
Start-Process wusa.exe -ArgumentList "/uninstall /KB:$Hotfix /quiet /norestart" -Wait
}编辑: EventViewer sais (翻译)这个:
Due to an error, the Windows-Update could not be uninstalled.
Error: 2147942487 "Wrong Parameter."
(CommandLine:""C:\WINDOWS\system32\wusa.exe" /uninstall /KB:4054517 /quiet /norestart ")发布于 2018-03-02 21:21:15
这里有一个简单的一行代码来做同样的事情。
(get-hotfix).hotfixid.replace("KB","") | % {& wusa.exe /uninstall /KB:$_ /quiet /norestart}就你的问题而言,你做得很对。通过一些快速的谷歌搜索,你有可能有一个损坏的修补程序,但可能性不大。有趣的是,当我试图卸载一个带有虚假KB代码的应用程序时,它给出了一个不同的错误代码。
对于错误,尝试只卸载抛出错误的特定修补程序,并报告事件日志显示的内容/ WUSA显示的内容。
也就是说(没有静音,所以你可以看到它说了什么)
wusa.exe /uninstall /KB:4054517 /norestart
https://stackoverflow.com/questions/49068043
复制相似问题