如何解除安裝 PowerShell 模組?
要解除安裝 PowerShell 模組,我們可以直接使用 Uninstall-Module 命令,但模組不應該處於使用狀態,否則會丟擲錯誤。
當我們使用 Uninstall-Module 命令時,它可以從當前使用者配置檔案或所有使用者配置檔案中解除安裝模組。
Uninstall-Module 7Zip4PowerShell -Force -Verbose
另一種方法,
Get-InstalledModule 7Zip4Powershell | Uninstall-Module -Force -Verbose
如果在 PowerShell 中安裝了同一模組的多個版本,並且想要解除安裝所有版本,則使用-AllVersions 引數。
Uninstall-Module 7Zip4PowerShell -AllVersions -Force -Verbose
如果要解除安裝特定版本,可以使用 -RequiredVersion。
Uninstall-Module 7Zip4PowerShell -RequiredVersion 1.5.0 -Force -Verbose
要在遠端計算機上解除安裝,請使用 Invoke-Command 方法。
Invoke-Command -ComputerName RemoteComputer1 -ScriptBlock { Uninstall-Module 7Zip4PowerShell -RequiredVersion 1.5.0 -Force -Verbose }
廣告