Powershell ISE是否支持aws cli?

问题描述 投票:0回答:1

我已经在Powershell上配置了AWS CLI,并且一切正常,但是当我尝试从Powershell ISE运行该命令时,Powershell ISE似乎无法识别aws命令完全没有

[让我开始思考,Powershell ISE是否支持AWS CLI?如果可以,我是否缺少一些环境变量配置?如果没有,那么背后是否有任何特殊原因?

amazon-web-services powershell aws-cli powershell-ise
1个回答
0
投票

尽管有ISE ...

您需要导入AWS模块才能使用它,就像其他任何出于某种原因而不会自动加载的PowerShell模块一样。

根据AWS PowerShell技术文档。

设置适用于Windows PowerShell的AWS工具 https://docs.amazonaws.cn/powershell/latest/userguide/pstools-getting-set-up.html

将PowerShell工具模块加载到当前会话中

打开PowerShell提示符并键入以下命令:

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

注意

在PowerShell 4.0和更高版本中,导入模块还会搜索 用于已安装模块的Program Files文件夹,因此没有必要 提供模块的完整路径。您可以运行以下命令 导入AWSPowerShell模块。在PowerShell 3.0及更高版本中, 在模块中运行cmdlet也会自动导入模块 进入您的会话。

Import-Module AWSPowerShell

根据我非常自定义的ISE配置文件中与AWS的混淆。

(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
...
#>
© www.soinside.com 2019 - 2024. All rights reserved.