WUA API 找不到更新

WUA API unable to find update

代码示例:

$UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'

$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
$Updates = $UpdateSearcher.Search('IsInstalled=1')

$Updates | Where-Object { $_.Title -like '*KB2506143*' }

我正在尝试以编程方式卸载 WMF3,但在尝试使用 wusa.exe、

时我总是遇到错误
wusa /uninstall /kb:2506143 /quiet /norestart /log:C:\log.evt

CbsClient::CbsClient.00110: Failed to create a CBS session instance
CbsClient::CbsClient.00127: Exit with error code 0X80040154 (Class not registered)
UninstallWorker.00664: Start of search
CbsClient::OpenPackageByKB.00268: CBS session is not initialized.
CbsClient::OpenPackageByKB.00320: Exit with error code 0X8000ffff (Catastrophic failure)
UninstallWorker.00667: Failed: OpenPackageByKB() for KB2506143
UninstallWorker.00799: Exit with error code 0X8000ffff (Catastrophic failure)
RebootIfRequested.01446: Reboot is not scheduled. IsRunWizardStarted: 0, IsRebootRequired: 0, RestartMode: 1
Windows update could not be uninstalled because of error 2147549183 "Catastrophic failure" (Command line: "C:\windows\System32\wusa.exe /uninstall /kb:2506143 /quiet /norestart /log:C:\log.evt")
wWinMain.01962: Failed to uninstall update ; Error: 0X8000ffff, Catastrophic failure. Command line: C:\windows\System32\wusa.exe /uninstall /kb:2506143 /quiet /norestart /log:C:\log.evt
wWinMain.01998: Exit with error code 0X8000ffff (Catastrophic failure)

所以我打算使用用水户协会 API。上面的代码片段给了我 $Null return,但我可以使用 Get-Hotfix -ID KB2506143Get-WmiObject -Class Win32_QuickFixEngineering -Filter 'HotFixID="KB2506143"' 来查找更新。

类似,但是在找到补丁后尝试卸载时访问被拒绝,而我的问题是:如何在第一个中找到补丁地点?

我不确定补丁是如何应用的,所以如果我 运行 找到它后遇到同样的问题,我至少有 that resolution

所以所有这一切的目的是以编程方式升级到 WMF5.1,我找到了一个解决方法来解决我试图完成的问题。 PowerShell v3 在构建过程中使用 DISM 在 OS 中启用,并且不能被 WUA 删除,因为它不是由 WUA 放置在那里的。


解决方法 1:

dism.exe /Online /Disable-Feature:MicrosoftWindowsPowerShellV3

这会将 $PSVersionTable 降级为 v2,但不会删除补丁程序 KB2506143。这导致需要通过 UI 手动卸载它,所以它并没有真正完成我需要的。


解决方法 2:

WMF3 无法升级到 WMF5,但可以升级到 WMF4,然后是 WMF5(.1)。

最终,我使用 wusa.exe 在 WMF3 上安装了 WMF4,同时仍然在 dism 中禁用了 v3,并且在重新启动后成功地在 WMF4 上安装了 WMF5.1(再次使用 wusa.exe)。

限制的根源在于 WUA 无法管理它未安装的补丁(通过 .msu 或 WSUS)