简体   繁体   English

无法安装/使用 AWS 工具 Powershell cmdlet

[英]Unable to install/use AWS Tools Powershell cmdlets

I have tried using the basic commands from multiple websites and videos , but after installing AWS.Tools.Installer and AWS.Tools.S3 I get the same error when trying to use a command:我尝试使用来自多个网站视频基本命令,但在安装 AWS.Tools.Installer 和 AWS.Tools.S3 后,尝试使用命令时出现相同的错误:

Set-Awscredentials : The term 'Set-Awscredentials' is not recognized
as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that
the path is correct and try again. At line:1 char:1
+ Set-Awscredentials
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-Awscredentials:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I've got multiple freshly imaged machines in our lab running Windows 10 Enterprise LTSC 2019 build 1809 and the result is the same on all of them.我在我们的实验室中有多台新成像的机器运行Windows 10 Enterprise LTSC 2019 build 1809 ,所有机器的结果都相同。 Here are the commands I run from an Admin prompt , in the order I run them, and they complete without issue:以下是我从管理员提示符运行的命令,按照我运行它们的顺序,它们完成没有问题:

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSrepository PSGallery -InstallationPolicy Trusted
Set-ExecutionPolicy Unrestricted -Force
Install-Module -Name AWS.Tools.Installer -Force -Confirm:$false -AllowClobber -Scope AllUsers
Install-AWSToolsModule -Name AWS.Tools.S3 -CleanUp -Confirm:$false -Verbose -Force
Get-Module -ListAvailable | ? Name -Like 'AWS.Tools.*'

Also of note, I actually ran them with each in a try/catch statement, where the catch exits, but I did not include that code for brevity's sake.另外值得注意的是,我实际上在 try/catch 语句中运行了它们,其中 catch 退出,但为了简洁起见,我没有包含该代码。 These computers are not joined to a domain, so unexpected GPO settings shouldn't affect it.这些计算机未加入域,因此意外的 GPO 设置不应影响它。

In the above script, I did the AWS.Tools.S3 as Verbose, here's the output for that:在上面的脚本中,我将 AWS.Tools.S3 设置为 Verbose,这里是 output:

VERBOSE: [Install-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue Force=True
Name=(AWS.Tools.S3) RequiredVersion= SkipUpdate=False CleanUp=False 
VERBOSE: [Find-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue
Name=(AWS.Tools.S3) VERBOSE: [Find-AWSToolsModule] End 
VERBOSE: [Install-AWSToolsModule] Installing AWS Tools version 4.1.11.0 
VERBOSE: [Install-AWSToolsModule] Searching installed modules 
VERBOSE: [Install-AWSToolsModule] Removing already installed modules from the. Final list of modules to install:
(AWS.Tools.S3) 
VERBOSE: [Install-AWSToolsModule] Create folder for temporary repository C:\Windows\TEMP\q3a2lhx5.t03 
VERBOSE: [Install-AWSToolsModule] Registering temporary repository AWSToolsTemp 
VERBOSE: [Install-AWSToolsModule] Downloading modules to temporary repository 
VERBOSE: [Install-AWSToolsModule] Downloading modules (AWS.Tools.S3) 
VERBOSE: [Install-AWSToolsModule] Downloading module AWS.Tools.S3 to C:\Windows\TEMP\q3a2lhx5.t03 
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] ConfirmPreference=None WhatIfPreference=False
VerbosePreference=Continue Name=AWS.Tools.S3 Path=C:\Windows\TEMP\q3a2lhx5.t03\AWS.Tools.S3.4.1.11.0.nupkg 
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Manifest signature correctly validated 
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Found dependency AWS.Tools.Common 
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] End 
VERBOSE: [Install-AWSToolsModule] Downloading module AWS.Tools.Common to C:\Windows\TEMP\q3a2lhx5.t03 
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] ConfirmPreference=None WhatIfPreference=False
VerbosePreference=Continue Name=AWS.Tools.Common Path=C:\Windows\TEMP\q3a2lhx5.t03\AWS.Tools.Common.4.1.11.0.nupkg 
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Manifest signature correctly validated 
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] End 
VERBOSE: [Install-AWSToolsModule] Installing modules (AWS.Tools.S3) Installing module AWS.Tools.S3 version 4.1.11.0 
VERBOSE: [Install-AWSToolsModule] Modules install complete 
VERBOSE: [Install-AWSToolsModule] Unregistering temporary repository AWSToolsTemp 
VERBOSE: [Install-AWSToolsModule] Delete repository folder C:\Windows\TEMP\q3a2lhx5.t03 
VERBOSE: [Install-AWSToolsModule] End 

After running that, I tried the following to confirm they were in the correct directories:运行后,我尝试了以下操作以确认它们位于正确的目录中:

ls 'C:\Program Files\WindowsPowerShell\Modules'
ls 'C:\Users\Kiosk\Documents\WindowsPowerShell\Modules'
Write-Host '-----------------------------------------------------------------------'
Get-Module -ListAvailable | ? Name -Like 'AWS.Tools.*'

And this is what it gives me:这就是它给我的:

Directory: C:\Program Files\WindowsPowerShell\Modules


Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/22/2021 11:02 AM AWS.Tools.Installer
d----- 9/15/2018 3:33 AM Microsoft.PowerShell.Operation.Validation
d----- 4/22/2021 11:02 AM PackageManagement
d----- 9/15/2018 3:33 AM Pester
d----- 4/22/2021 11:02 AM PowerShellGet
d----- 9/15/2018 3:33 AM PSReadline
d----- 9/4/2020 5:05 PM PSWindowsUpdate
-----------------------------------------------------------------------
Name : AWS.Tools.Installer
Path : C:\Program Files\WindowsPowerShell\Modules\AWS.Tools.Installer\1.0.2.1\AWS.Tools.Installer.psd1
Description : The AWS.Tools.Installer module makes it easier to install, update and uninstall other AWS.Tools
modules (see https://www.powershellgallery.com/packages/AWS.Tools.Common/).
You can use a single command like 'Install-AWSToolsModule EC2,S3' to install multiple modules.
You can also update all your installed AWS.Tools modules and remove old versions by running
`Update-AWSToolsModule -CleanUp`.
Guid : 450031c1-9177-4fc1-9518-93166b1a926b
Version : 1.0.2.1
ModuleBase : C:\Program Files\WindowsPowerShell\Modules\AWS.Tools.Installer\1.0.2.1
ModuleType : Script
PrivateData : {PSData}
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Uninstall-AWSToolsModule, Uninstall-AWSToolsModule], [Install-AWSToolsModule,
Install-AWSToolsModule], [Update-AWSToolsModule, Update-AWSToolsModule]}
ExportedVariables : {}
NestedModules : {}

I have tried running the AWS Installer module with我试过运行 AWS Installer 模块

powershell -NoProfile -command 'Install-AWSToolsModule -Name AWS.Tools.S3 -CleanUp -Confirm:$false -Verbose -Force'

Although these machines have never had any powershell run on them before I ran the first script.尽管在我运行第一个脚本之前,这些机器上从未运行过任何 powershell。 It just looks like the S3 module is not installing and I see no reason why.看起来 S3 模块没有安装,我看不出原因。 I am at the end of my rope with this one.我已经走到了尽头。 Does anyone see what I am missing?有人看到我错过了什么吗? Thanks!谢谢!

Also, here is my $PSVersionTable:另外,这是我的 $PSVersionTable:

Name Value
---- -----
PSVersion 5.1.17763.1007
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1007
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1 

Though you can download and install the PS AWS tools, they are already available to you via MS powershellgallery.com (as stated on the AWS PS Tool site - https://aws.amazon.com/powershell ).虽然您可以下载并安装 PS AWS 工具,但您已经可以通过 MS powershellgallery.com 获得它们(如 AWS PS 工具网站上所述 - https://aws.amazon.com/powershell )。

https://www.powershellgallery.com/packages/AWS.Tools.Common/4.1.11.0

From your active PS instance (VSCode/ISE/Consolehost/Windows Terminal), just type...从您的活动 PS 实例(VSCode/ISE/Consolehost/Windows 终端)中,只需键入...

Install-Module -Name AWS.Tools.Common

... or if you want to cherry-pick, from your active PS instance (VSCode/ISE/Consolehost/Windows Terminal) just type (be patient, there is a bunch) ... ...或者如果您想挑选,从您的活动 PS 实例(VSCode/ISE/Consolehost/Windows 终端)中输入(请耐心等待,有一堆) ...

Find-Module -Name '*AWS*' | 
Where-Object -Property Author -eq 'Amazon.com Inc' | 
Sort-Object -Property Version
Format-Table -AutoSize
# Results
<#
Version    Name                                Repository           Description                                                                                                 
-------    ----                                ----------           -----------                                                                                                 
1.0.2.1    AWS.Tools.Installer                 PSGallery            The AWS.Tools.Installer module makes it easier to install,...
2.0.0.0    AWSLambdaPSCore                     PSGallery            The AWS Lambda Tools for Powershell can be used to create ...
4.1.11.0   AWSPowerShell                       PSGallery            The AWS Tools for Windows PowerShell lets developers and...
4.1.11.0   AWS.Tools.MarketplaceCatalog        PSGallery            The MarketplaceCatalog module of AWS Tools for PowerShe...
4.1.11.0   AWS.Tools.WorkMailMessageFlow       PSGallery            The WorkMailMessageFlow module of AWS Tools for PowerShe...
4.1.11.0   AWS.Tools.ComputeOptimizer          PSGallery            The ComputeOptimizer module 
...
#>

... to see them, and install them the normal way... ...查看它们,并以正常方式安装它们...

$InstallAwsModules = 'Whatever Module name/Names you choose as a list'
$InstallAwsModules | 
ForEach {
    Find-Module -Name $PSItem
    Save-Module -Path "$env:USERPROFILE\\Documents\WindowsPowerShell\Modules" -Force
    Install-Module -Name $PSItem
}

You can, as you've tried, use the AWS installer tool.您可以尝试使用 AWS 安装程序工具。 However, there is zero reasons to do this...但是,这样做的理由为零……

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

..., as PSGet is the package manager for PowerShell, and already leverages NuGet,... ...,因为 PSGet 是 PowerShell 的 package 管理器,并且已经利用 NuGet,...

to make sure you are on the most recent package manager, run this...要确保您使用的是最新的 package 管理器,请运行此...

powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'

... so installing NuGet again is redundant, as well as there is no need for this... ...因此再次安装 NuGet 是多余的,并且不需要这个...

powershell -NoProfile -command 'Install-AWSToolsModule -Name AWS.Tools.S3 -CleanUp -Confirm:$false -Verbose -Force'

..., just download the AWS PS zip, open Windows Explorer, unblock it, and install the modules. ...,只需下载 AWS PS zip,打开 Windows 资源管理器,取消阻止,然后安装模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM