the_coder_in_me
the_coder_in_me

Reputation: 143

ObjectNotFound Error while using cmdlet to access AWS IAM

I am trying to generate AWS API gateway access key through powershell. However, everytime I try to use any cmdlet it throws an error:

For example:

 Get-AWSCredential -ListProfileDetail

will result in an error like this:

Get-AWSCredential : The term 'Get-AWSCredential' 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 + Get-AWSCredential -ListProfileDetail + ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-AWSCredential:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

When I display the list of commands through Get-Command the AWS cmdlets do not pop up. Any idea what could be the problem?

Upvotes: 2

Views: 9228

Answers (2)

Ermiya Eskandary
Ermiya Eskandary

Reputation: 23592

Since November 2019, AWS now provide a modularised, lighter version of AWS Tools for PowerShell called AWS.Tools.*.

I recommend using these modules over AWSPowerShell, which is the single, large-module version and will most likely include way more than you need.

You need the AWS.Tools.IdentityManagement module for IAM-related commands e.g. Get-AWSCredential / Get-IAMUser.

Recommended setup using AWS.Tools.Installer (multiple benefits1):

Install-Module -Name AWS.Tools.Installer
Install-AWSToolsModule AWS.Tools.IdentityManagement

Minimal setup:

Install-Module -Name AWS.Tools.Common
Install-Module -Name AWS.Tools.IdentityManagement

1: as per above docs

The AWS.Tools.Installer module simplifies the installation and update of other AWS.Tools modules. AWS.Tools.Installer requires, automatically downloads and installs, an updated version of PowerShellGet. The AWS.Tools.Installer module also automatically keeps your module versions in sync. When you install or update to a newer version of one module, the cmdlets in the AWS.Tools.Installer automatically update all of your other AWS.Tools modules to the same version.

Upvotes: 0

Jacob Barnes
Jacob Barnes

Reputation: 1560

Long story short, run this: Install-Package -Name AWSPowerShell

You may need to run PS as an Administrator for the Install-Package command to work. Additionally, you may be prompted to install 'nuget', answer yes. If you receive the security warning about PSGallery, answer yes.

Here is Amazon's docs on PS cmdlets: http://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up.html

Upvotes: 15

Related Questions