0

I have configured AWS CLI on my Powershell and everything works fine but when I tried to run the same from Powershell ISE, It seemed that Powershell ISE did not recognize aws command at all.

It got me thinking, whether AWS CLI is supported on Powershell ISE? If it does, am I missing some configuration with environmental variables? If it doesn't, is there any particular reason behind it?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Try restarting the ISE. There should be no difference in what programs you can call by mere filename, such as `aws`; if there is, check your `$PROFILE` file from a regular PowerShell session to see if `$env:PATH` additions are made there that the ISE - which has its own `$PROFILE` - doesn't see. – mklement0 Apr 04 '20 at 18:11
  • As an aside: The PowerShell ISE is [no longer actively developed](https://learn.microsoft.com/en-us/powershell/scripting/components/ise/introducing-the-windows-powershell-ise#support) and [there are reasons not to use it](https://stackoverflow.com/a/57134096/45375) (bottom section). The editor that offers the best PowerShell development experience, across platforms, is [Visual Studio Code](https://code.visualstudio.com/), combined with its [PowerShell extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell), which is under active development. – mklement0 Apr 04 '20 at 18:11
  • try to add .exe to aws command u run, example: `aws.exe --region cognito-idp list-users --user-pool-id --output json` – Elnur Mammadov Nov 25 '20 at 16:15

1 Answers1

0

ISE notwithstanding...

Your need to import the AWS module to use it, just as you would any other PowerShell module that does not autoload for whatever reason.

As per the AWS PowerShell technical docs.

Setting up the AWS Tools for Windows PowerShell https://docs.amazonaws.cn/powershell/latest/userguide/pstools-getting-set-up.html

To load the PowerShell Tools module into your current session

Open a PowerShell prompt and type the following command:

Import-Module "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1"

Note

In PowerShell 4.0 and later releases, Import-Module also searches the Program Files folder for installed modules, so it is not necessary to provide the full path to the module. You can run the following command to import the AWSPowerShell module. In PowerShell 3.0 and later, running a cmdlet in the module also automatically imports a module into your session.

Import-Module AWSPowerShell

As per messing with AWS in my very customized ISE profile.

(Get-CimInstance -ClassName Win32_OperatingSystem).Caption
<#
# Results

Microsoft Windows 10 Pro
#>

$psISE
<#
CurrentPowerShellTab         : Microsoft.PowerShell.Host.ISE.PowerShellTab
CurrentFile                  : Microsoft.PowerShell.Host.ISE.ISEFile
CurrentVisibleHorizontalTool : 
CurrentVisibleVerticalTool   : Microsoft.PowerShell.Host.ISE.ISEAddOnTool
Options                      : Microsoft.PowerShell.Host.ISE.ISEOptions
PowerShellTabs               : {PowerShell 1}
#>

Import-Module -Name AWSPowerShell -Verbose
<# 
# Results

VERBOSE: Loading module from path 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSSDK.ACMPCA.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSSDK.ACMPCA.dll'.
....
#>

Get-Module -Name '*aws*' | 
Format-Table -AutoSize
<#
# Results

ModuleType Version    Name                                ExportedCommands                                                                                                                 
---------- -------    ----                                ----------------                                                                                                                 
Binary     3.3.618.0  AWSPowerShell                       {Add-AASScalableTarget, Add-ACMCertificateTag, ...

#>

Get-Command -Name '*aws*' | 
Format-Table -AutoSize
<#
# Results

CommandType Name                                   Version   Source          
----------- ----                                   -------   ------          
Alias       Clear-AWSCredentials                   4.0.5.0   AWS.Tools.Common
Alias       Clear-AWSCredentials                   4.0.0.0   AWS.Tools.Common
Alias       Clear-AWSCredentials                   3.3.618.0 AWSPowerShell   
...
#>

Get-Command -Module AWSPowerShell | 
Format-Table -AutoSize
<#
# Results

CommandType     Name                               Version    Source
-----------     ----                               -------    ------
Alias           Add-ALXBContactWithAddressBook     3.3.618.0  AWSPowerShell
Alias           Add-ASInstances                    3.3.618.0  AWSPowerShell
Alias           Add-CTTag                          3.3.618.0  AWSPowerShell
#>

Get-Command -Module AWSPowerShell -CommandType Cmdlet | 
Format-Table -AutoSize
<#
# Results

CommandType Name                                                           Version   Source       
----------- ----                                                           -------   ------       
Cmdlet      Add-AASScalableTarget                                          3.3.618.0 AWSPowerShell
Cmdlet      Add-ACMCertificateTag                                          3.3.618.0 AWSPowerShell
Cmdlet      Add-ADSConfigurationItemsToApplication                         3.3.618.0 AWSPowerShell
...
#>
postanote
  • 15,138
  • 2
  • 14
  • 25