简体   繁体   中英

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:

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. 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. These computers are not joined to a domain, so unexpected GPO settings shouldn't affect it.

In the above script, I did the AWS.Tools.S3 as Verbose, here's the output for that:

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

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. It just looks like the S3 module is not installing and I see no reason why. I am at the end of my rope with this one. Does anyone see what I am missing? Thanks!

Also, here is my $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 ).

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

From your active PS instance (VSCode/ISE/Consolehost/Windows Terminal), just type...

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) ...

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. 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,...

to make sure you are on the most recent package manager, run this...

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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