簡體   English   中英

如何使用 Powershell 卸載軟件更新(程序和功能\已安裝的更新)

[英]How can I uninstall Software Update (Programs and Features\Installed Updates) with Powershell

是否有一種簡單的方法可以卸載程序和功能\已安裝的 Powershell 中列出的軟件更新(服務包)?

我不是在談論 Windows 更新。 但是在 win 更新所在的同一位置列出的特定軟件 Service Pack。

我知道如何使用 PS 卸載程序和功能中列出的軟件但不知道如何刪除軟件更新/服務包

此命令將列出所有軟件

Get-WmiObject -Class Win32_Product | Select-Object -Property Name

或者這個

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate,UninstallString | Format-Table –AutoSize

這將刪除軟件,但我只需要刪除軟件服務包(更新),

$app = Get-WmiObject -Class Win32_Product | Where-Object { 
    $_.Name -match "Software Name" 
}

$app.Uninstall()

我已經看過那篇文章: 如何使用 PowerShell 卸載應用程序?

我希望我足夠清楚,謝謝

長話短說,我需要一個命令來列出或/和刪除選定的軟件更新(服務包等),謝謝

任何想法,謝謝

您是否嘗試過搜索任何類似的主題? 我發現像 9+

你要找的是這個:

$app = Get-WmiObject -Class Win32_Product | Where-Object { 
    $_.Name -match "Software Name" 
}

$app.Uninstall()

或者, $app = Get-WmiObject -Class Win32_Product -Filter "Name = 'Software Name'"

摘自: 如何使用 PowerShell 卸載應用程序?

其他有用的鏈接:

https://redmondmag.com/articles/2019/08/27/powershell-to-uninstall-an-application.aspx

https://www.slashadmin.co.uk/how-to-uninstall-programs-using-powershell/

所有與調用.uninstall方法的結論相同。

更新:

我們還可以使用 DISM 進行更新:

$SearchUpdates = dism /online /get-packages | findstr "Package_for"
$updates = $SearchUpdates.replace("Package Identity : ", "") | findstr "KBXXXXXX"
#$updates
DISM.exe /Online /Remove-Package /PackageName:$updates /quiet /norestart

Get-Packageuninstall-package的本機 powerhsell cmdlet。

將此快速腳本作為您更新的選擇。

$Updates = Get-Package -Name "*Update*" | Select-Object -ExpandProperty Name
for($i=0; $i -lt $Updates.Count; $i++){
write-host "$($i): $($Updates[$i])"    
    }

$Selection = Read-Host -Prompt "Enter number of updates you would like to uninstall"
$Selection = $Selection -split " "


Foreach($Update in $Updates[$Selection]){
    Uninstall-Package -Name $Update -whatif
    }

如果您熟悉它的語法, Wusa.exe也可以為您提供類似的結果。 運行wusa.exe /? . 例如: Wusa /uninstall /KB:KB1234567

請注意,我過去只是使用 Wusa 卸載 KB 才真正成功。 DISM 似乎大部分時間都在工作,但有很多可用的選項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM