Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 删除已安装的Windows修补程序_Powershell_Powershell 5.0 - Fatal编程技术网

Powershell 删除已安装的Windows修补程序

Powershell 删除已安装的Windows修补程序,powershell,powershell-5.0,Powershell,Powershell 5.0,我正在尝试编写一个小脚本来删除Win 10机器上安装的所有修补程序。因为我没有找到一个能够实现此功能的模块,所以我使用了Start Process wusa.exe-ArgumentList 虽然文本文件确实只包含ArgumentList中变量所需的纯数字(否则它将是KB1234565),但什么也不会发生 我不知道如何去看wusa到底做了什么,所以我被一些不起作用的东西困住了,但我不知道为什么 Powershell 5.1.16299.98,ExecutionPolicy未签名,提升了本地Adm

我正在尝试编写一个小脚本来删除Win 10机器上安装的所有修补程序。因为我没有找到一个能够实现此功能的模块,所以我使用了
Start Process wusa.exe-ArgumentList

虽然文本文件确实只包含ArgumentList中变量所需的纯数字(否则它将是KB1234565),但什么也不会发生

我不知道如何去看wusa到底做了什么,所以我被一些不起作用的东西困住了,但我不知道为什么

Powershell 5.1.16299.98,ExecutionPolicy未签名,提升了本地AdminAccount上的shell

#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 SAI(已翻译)此:


这里有一个简单的单行程序,它做同样的事情

(get-hotfix).hotfixid.replace("KB","") | % {& wusa.exe /uninstall /KB:$_ /quiet /norestart}
就你的问题而言,你做得对。通过一些快速的谷歌搜索,你可能有一个损坏的修补程序,但不太可能。有趣的是,当我试图用伪造的KB代码卸载一个时,它会给我一个不同的错误代码

对于错误,请尝试仅卸载引发错误的特定修补程序,并报告事件日志所说的/what
WUSA
所说的

i、 (没有安静,所以你可以看到它说什么)


wusa.exe/uninstall/KB:4054517/norestart

您想要实现什么?卸载操作系统更新通常不是一个好主意。我对一些随机挂起任务的电脑有一些奇怪的问题,所以我想我卸载所有更新并手动逐个重新安装。我知道我可以通过另一种方式实现同样的目标,但我猜启动流程-ArgumentList部分将以这种或那种方式再次出现。即使PS被提升,也有可能是
wusa
作为非提升流程启动,因为您使用的是
Start Process
。尝试将
-动词runAs
添加到
启动进程
,因为这将提升进程。如果没有
/quiet
,它可以工作,但需要用户交互。我现在没问题。不幸的是,RunAs一点帮助都没有。
(get-hotfix).hotfixid.replace("KB","") | % {& wusa.exe /uninstall /KB:$_ /quiet /norestart}