如何从PowerShell卸载AWSPowerShell/AWS.Tools模块?

iih3973s  于 2022-11-10  发布在  Shell
关注(0)|答案(2)|浏览(145)

PowerShell的第一步。我无法从AWS安装的模块中删除/卸载AWSPowerShell模块。Get-Module -Name AWSPowerShell,AWSPowerShell.NetCore,AWS.Tools.Common -ListAvailable如下所示:

Directory: C:\Users\user\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     4.1.14.0              AWS.Tools.Common                    Core,Desk {Clear-AWSHistory, Set-AWSHistoryConfiguration, Initialize-AWSDefaultConfi…

    Directory: C:\Program Files (x86)\AWS Tools\PowerShell

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     3.3.509.0             AWSPowerShell                       Desk

当我尝试通过Uninstall-Module -Name AWSPowerShell卸载它时,我收到错误:

Uninstall-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:12733
 Line |
12733 |  …        $null = PackageManagement\Uninstall-Package @PSBoundParameters
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | No match was found for the specified search criteria and module names 'AWSPowerShell'.

问题--我怎样才能摆脱这个问题?

g52tjvyc

g52tjvyc1#

您只需将其删除即可。如果你想通过PowerShell做到这一点,你可以这样做:

Get-Module -Name <ModuleName> -ListAvailable | Select-Object -ExpandProperty ModuleBase | Remove-Item -Recurse -Force
wecizke3

wecizke32#

要安装AWSPowerShell模块,需要将文件夹放入

C:\Program Files\WindowsPowerShell\Modules

之后,您可以执行以下命令来安装模块:

Import-Module AWSPowerShell

现在,应该在客户端上安装AWSPowerShell
如果要删除AWSPowerShell,则需要执行以下命令:

Remove-Module AWSPowerShell

删除模块后,您可以删除该文件夹:

C:\Program Files\WindowsPowerShell\Modules\AWSPowerShell

有关这些命令的更多信息,请访问Microsoft Wiki:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/import-module?view=powershell-7.2
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/remove-module?view=powershell-7.2

相关问题