

のバージョン 5 (V5) AWS Tools for PowerShell がリリースされました。

重要な変更とアプリケーションの移行については、[「移行トピック](https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html)」を参照してください。

 [https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html](https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# コマンドレットの検出とエイリアス
<a name="pstools-discovery-aliases"></a>

このセクションでは、 でサポートされているサービスを一覧表示する方法 AWS Tools for PowerShell、それらのサービス AWS Tools for PowerShell をサポートするために によって提供されるコマンドレットのセットを表示する方法、およびそれらのサービスにアクセスするための代替コマンドレット名 (エイリアスとも呼ばれます) を見つける方法について説明します。

## コマンドレットの検出
<a name="pstools-cmdlet-discovery"></a>

すべての AWS サービスオペレーション (または APIsは、各サービスの API リファレンスガイドに記載されています。例えば、「[IAM API リファレンス](https://docs.aws.amazon.com/IAM/latest/APIReference/)」を参照してください。ほとんどの場合、 AWS サービス API と AWS PowerShell コマンドレットの間には one-to-one の通信があります。 AWS サービス API 名に対応するコマンドレット名を取得するには、 `-ApiOperation`パラメータと AWS サービス API `Get-AWSCmdletName` 名を使用してコマンドレットを実行します AWS 。たとえば、使用可能な`DescribeInstances` AWS サービス API に基づいて使用可能なすべてのコマンドレット名を取得するには、次のコマンドを実行します。

```
PS > Get-AWSCmdletName -ApiOperation DescribeInstances

CmdletName        ServiceOperation    ServiceName                    CmdletNounPrefix
----------        ----------------    -----------                    ----------------
Get-EC2Instance   DescribeInstances   Amazon Elastic Compute Cloud   EC2
Get-GMLInstance   DescribeInstances   Amazon GameLift Service        GML
```

`-ApiOperation` パラメータはデフォルトのパラメータなので、パラメータ名は省略できます。次の例は、前の例と同等です。

```
PS > Get-AWSCmdletName DescribeInstances
```

API とサービスの両方の名前がわかっている場合は、 コマンドレット名プレフィックスまたは AWS サービス名の一部に `-Service`パラメータを含めることができます。たとえば、Amazon EC2 のコマンドレット名プレフィックスは `EC2` です。Amazon EC2 サービスの `DescribeInstances` API に対応するコマンドレット名を取得するには、以下のいずれかのコマンドを実行します。どのコマンドでも同じ出力になります。

```
PS > Get-AWSCmdletName -ApiOperation DescribeInstances -Service EC2
PS > Get-AWSCmdletName -ApiOperation DescribeInstances -Service Compute
PS > Get-AWSCmdletName -ApiOperation DescribeInstances -Service "Compute Cloud"

CmdletName        ServiceOperation    ServiceName                    CmdletNounPrefix
----------        ----------------    -----------                    ----------------
Get-EC2Instance   DescribeInstances   Amazon Elastic Compute Cloud   EC2
```

これらのコマンドのパラメータ値では、大文字と小文字が区別されません。

目的の AWS サービス API または AWS サービスの名前がわからない場合は、 `-ApiOperation`パラメータと、一致するパターン、および `-MatchWithRegex`パラメータを使用できます。たとえば、`SecurityGroup` を含むすべてのコマンドレット名を取得するには、次のコマンドを実行します。

```
PS > Get-AWSCmdletName -ApiOperation SecurityGroup -MatchWithRegex

CmdletName                                    ServiceOperation                            ServiceName                        CmdletNounPrefix
----------                                    ----------------                            -----------                        ----------------
Approve-ECCacheSecurityGroupIngress           AuthorizeCacheSecurityGroupIngress          Amazon ElastiCache                 EC
Get-ECCacheSecurityGroup                      DescribeCacheSecurityGroups                 Amazon ElastiCache                 EC
New-ECCacheSecurityGroup                      CreateCacheSecurityGroup                    Amazon ElastiCache                 EC
Remove-ECCacheSecurityGroup                   DeleteCacheSecurityGroup                    Amazon ElastiCache                 EC
Revoke-ECCacheSecurityGroupIngress            RevokeCacheSecurityGroupIngress             Amazon ElastiCache                 EC
Add-EC2SecurityGroupToClientVpnTargetNetwrk   ApplySecurityGroupsToClientVpnTargetNetwork Amazon Elastic Compute Cloud       EC2
Get-EC2SecurityGroup                          DescribeSecurityGroups                      Amazon Elastic Compute Cloud       EC2
Get-EC2SecurityGroupReference                 DescribeSecurityGroupReferences             Amazon Elastic Compute Cloud       EC2
Get-EC2StaleSecurityGroup                     DescribeStaleSecurityGroups                 Amazon Elastic Compute Cloud       EC2
Grant-EC2SecurityGroupEgress                  AuthorizeSecurityGroupEgress                Amazon Elastic Compute Cloud       EC2
Grant-EC2SecurityGroupIngress                 AuthorizeSecurityGroupIngress               Amazon Elastic Compute Cloud       EC2
New-EC2SecurityGroup                          CreateSecurityGroup                         Amazon Elastic Compute Cloud       EC2
Remove-EC2SecurityGroup                       DeleteSecurityGroup                         Amazon Elastic Compute Cloud       EC2
Revoke-EC2SecurityGroupEgress                 RevokeSecurityGroupEgress                   Amazon Elastic Compute Cloud       EC2
Revoke-EC2SecurityGroupIngress                RevokeSecurityGroupIngress                  Amazon Elastic Compute Cloud       EC2
Update-EC2SecurityGroupRuleEgressDescription  UpdateSecurityGroupRuleDescriptionsEgress   Amazon Elastic Compute Cloud       EC2
Update-EC2SecurityGroupRuleIngressDescription UpdateSecurityGroupRuleDescriptionsIngress  Amazon Elastic Compute Cloud       EC2
Edit-EFSMountTargetSecurityGroup              ModifyMountTargetSecurityGroups             Amazon Elastic File System         EFS
Get-EFSMountTargetSecurityGroup               DescribeMountTargetSecurityGroups           Amazon Elastic File System         EFS
Join-ELBSecurityGroupToLoadBalancer           ApplySecurityGroupsToLoadBalancer           Elastic Load Balancing             ELB
Set-ELB2SecurityGroup                         SetSecurityGroups                           Elastic Load Balancing V2          ELB2
Enable-RDSDBSecurityGroupIngress              AuthorizeDBSecurityGroupIngress             Amazon Relational Database Service RDS
Get-RDSDBSecurityGroup                        DescribeDBSecurityGroups                    Amazon Relational Database Service RDS
New-RDSDBSecurityGroup                        CreateDBSecurityGroup                       Amazon Relational Database Service RDS
Remove-RDSDBSecurityGroup                     DeleteDBSecurityGroup                       Amazon Relational Database Service RDS
Revoke-RDSDBSecurityGroupIngress              RevokeDBSecurityGroupIngress                Amazon Relational Database Service RDS
Approve-RSClusterSecurityGroupIngress         AuthorizeClusterSecurityGroupIngress        Amazon Redshift                    RS
Get-RSClusterSecurityGroup                    DescribeClusterSecurityGroups               Amazon Redshift                    RS
New-RSClusterSecurityGroup                    CreateClusterSecurityGroup                  Amazon Redshift                    RS
Remove-RSClusterSecurityGroup                 DeleteClusterSecurityGroup                  Amazon Redshift                    RS
Revoke-RSClusterSecurityGroupIngress          RevokeClusterSecurityGroupIngress           Amazon Redshift                    RS
```

 AWS サービスの名前がわかっていても AWS 、サービス API がわかっていない場合は、 `-MatchWithRegex` パラメータと `-Service`パラメータの両方を含めて、検索の範囲を 1 つのサービスに絞り込みます。たとえば、Amazon EC2 サービス内のみで、`SecurityGroup` を含むすべてのコマンドレット名を取得するには、次のコマンドを実行します。

```
PS > Get-AWSCmdletName -ApiOperation SecurityGroup -MatchWithRegex -Service EC2

CmdletName                                    ServiceOperation                            ServiceName                  CmdletNounPrefix
----------                                    ----------------                            -----------                  ----------------
Add-EC2SecurityGroupToClientVpnTargetNetwrk   ApplySecurityGroupsToClientVpnTargetNetwork Amazon Elastic Compute Cloud EC2
Get-EC2SecurityGroup                          DescribeSecurityGroups                      Amazon Elastic Compute Cloud EC2
Get-EC2SecurityGroupReference                 DescribeSecurityGroupReferences             Amazon Elastic Compute Cloud EC2
Get-EC2StaleSecurityGroup                     DescribeStaleSecurityGroups                 Amazon Elastic Compute Cloud EC2
Grant-EC2SecurityGroupEgress                  AuthorizeSecurityGroupEgress                Amazon Elastic Compute Cloud EC2
Grant-EC2SecurityGroupIngress                 AuthorizeSecurityGroupIngress               Amazon Elastic Compute Cloud EC2
New-EC2SecurityGroup                          CreateSecurityGroup                         Amazon Elastic Compute Cloud EC2
Remove-EC2SecurityGroup                       DeleteSecurityGroup                         Amazon Elastic Compute Cloud EC2
Revoke-EC2SecurityGroupEgress                 RevokeSecurityGroupEgress                   Amazon Elastic Compute Cloud EC2
Revoke-EC2SecurityGroupIngress                RevokeSecurityGroupIngress                  Amazon Elastic Compute Cloud EC2
Update-EC2SecurityGroupRuleEgressDescription  UpdateSecurityGroupRuleDescriptionsEgress   Amazon Elastic Compute Cloud EC2
Update-EC2SecurityGroupRuleIngressDescription UpdateSecurityGroupRuleDescriptionsIngress  Amazon Elastic Compute Cloud EC2
```

 AWS Command Line Interface （AWS CLI) コマンドの名前がわかっている場合は、 `-AwsCliCommand`パラメータと目的の AWS CLI コマンド名を使用して、同じ API に基づくコマンドレットの名前を取得できます。たとえば、Amazon EC2 サービスの`authorize-security-group-ingress` AWS CLI コマンド呼び出しに対応するコマンドレット名を取得するには、次のコマンドを実行します。

```
PS > Get-AWSCmdletName -AwsCliCommand "aws ec2 authorize-security-group-ingress"

CmdletName                    ServiceOperation              ServiceName                  CmdletNounPrefix
----------                    ----------------              -----------                  ----------------
Grant-EC2SecurityGroupIngress AuthorizeSecurityGroupIngress Amazon Elastic Compute Cloud EC2
```

コマンドレットは、サービスと AWS API `Get-AWSCmdletName` を識別するのに十分な AWS CLI コマンド名のみを必要とします。

Tools for PowerShell Core のすべてのコマンドレットを一覧表示するには、次の例に示すように PowerShell `Get-Command` コマンドレットを実行します。

```
PS > Get-Command -Module AWSPowerShell.NetCore
```

`-Module AWSPowerShell` で同じコマンドを実行すると、 AWS Tools for Windows PowerShellでコマンドレットを確認できます。

`Get-Command` コマンドレットは、コマンドレットをアルファベット順に一覧表示します。デフォルトでは、リストは PowerShell 名詞ではなく、PowerShell 動詞によってソートされます。

代わりに、サービスによって結果をソートするには、次のコマンドを実行します。

```
PS > Get-Command -Module AWSPowerShell.NetCore | Sort-Object Noun,Verb
```

`Get-Command` コマンドレットから返されたコマンドレットをフィルタリングするには、PowerShell の `Select-String` コマンドレットを実行します。たとえば、 AWS リージョンで動作するコマンドレットのセットを表示するには、次のコマンドを実行します。

```
PS > Get-Command -Module AWSPowerShell.NetCore | Select-String region

Clear-DefaultAWSRegion
Copy-HSM2BackupToRegion
Get-AWSRegion
Get-DefaultAWSRegion
Get-EC2Region
Get-LSRegionList
Get-RDSSourceRegion
Set-DefaultAWSRegion
```

コマンドレット名詞のサービスプレフィックスでフィルタすることで特定のサービスのコマンドレットを見つけることもできます。使用可能なサービスプレフィックスのリストを表示するには、`Get-AWSPowerShellVersion -ListServiceVersionInfo` を実行します。次の例では、Amazon CloudWatch Events サービスをサポートするコマンドレットが返されます。

```
PS > Get-Command -Module AWSPowerShell -Noun CWE*

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Add-CWEResourceTag                                 3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Disable-CWEEventSource                             3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Disable-CWERule                                    3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Enable-CWEEventSource                              3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Enable-CWERule                                     3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEEventBus                                    3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEEventBusList                                3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEEventSource                                 3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEEventSourceList                             3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEPartnerEventSource                          3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEPartnerEventSourceAccountList               3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEPartnerEventSourceList                      3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWEResourceTag                                 3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWERule                                        3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWERuleDetail                                  3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWERuleNamesByTarget                           3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Get-CWETargetsByRule                               3.3.563.1  AWSPowerShell.NetCore
Cmdlet          New-CWEEventBus                                    3.3.563.1  AWSPowerShell.NetCore
Cmdlet          New-CWEPartnerEventSource                          3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Remove-CWEEventBus                                 3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Remove-CWEPartnerEventSource                       3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Remove-CWEPermission                               3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Remove-CWEResourceTag                              3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Remove-CWERule                                     3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Remove-CWETarget                                   3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Test-CWEEventPattern                               3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Write-CWEEvent                                     3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Write-CWEPartnerEvent                              3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Write-CWEPermission                                3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Write-CWERule                                      3.3.563.1  AWSPowerShell.NetCore
Cmdlet          Write-CWETarget                                    3.3.563.1  AWSPowerShell.NetCore
```

## コマンドレットの名前付けとエイリアス
<a name="pstools-cmdlet-naming-aliases"></a>

 AWS Tools for PowerShell 各サービスの のコマンドレットは、サービスの AWS SDK によって提供される方法に基づいています。ただし、PowerShell の必須の命名規則のため、コマンドレットの名前は、それが基づく API コールやメソッドの名前とは異なる場合があります。たとえば、`Get-EC2Instance` コマンドレットは Amazon EC2 `DescribeInstances` メソッドに基づいています。

コマンドレット名とメソッド名が同じ場合でも、実際に実行される機能は異なることがあります。たとえば、Amazon S3 `GetObject` メソッドは Amazon S3 オブジェクトを取得します。一方、`Get-S3Object` コマンドレットは、オブジェクト自体ではなく、Amazon S3 オブジェクトに関する*情報*を返します。

```
PS > Get-S3Object -BucketName text-content -Key aws-tech-docs

ETag         : "df000002a0fe0000f3c000004EXAMPLE"
BucketName   : aws-tech-docs
Key          : javascript/frameset.js
LastModified : 6/13/2011 1:24:18 PM
Owner        : Amazon.S3.Model.Owner
Size         : 512
StorageClass : STANDARD
```

で S3 オブジェクトを取得するには AWS Tools for PowerShell、 `Read-S3Object` コマンドレットを実行します。

```
PS > Read-S3Object -BucketName text-content -Key text-object.txt -file c:\tmp\text-object-download.text

Mode          LastWriteTime            Length Name
----          -------------            ------ ----
-a---         11/5/2012   7:29 PM      20622  text-object-download.text
```

**注記**  
コマンドレットのコマンドレットヘルプは、 AWS コマンドレットが基づいている AWS SDK API の名前を提供します。  
標準の PowerShell 動詞とその意味の詳細については、「[Approved Verbs for PowerShell Commands](https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands)」を参照してください。

動`Remove`詞を使用するすべての AWS コマンドレット、および `Stop-EC2Instance` `-Terminate`パラメータを追加するときにコマンドレットを使用するすべてのコマンドレットは、続行する前に確認を求めます。確認を省略するには、コマンドに `-Force` パラメータを追加します。

**重要**  
AWS コマンドレットは`-WhatIf`スイッチをサポートしていません。

### エイリアス
<a name="pstools-aliases"></a>

のセットアップでは、多くの AWS コマンドレットのエイリアスを含むエイリアスファイル AWS Tools for PowerShell がインストールされます。これらのエイリアスは、コマンドレット名よりも直感的で理解しやすい場合があります。たとえば、サービス名と AWS SDK メソッド名は、一部のエイリアスの PowerShell 動詞と名詞を置き換えます。例として `EC2-DescribeInstances` エイリアスがあります。

また、標準の PowerShell 命名規則には従わないものの、実際のオペレーションよりもわかりやすい動詞を使用するエイリアスもあります。たとえば、エイリアスファイルでは、エイリアス `Get-S3Content` がコマンドレット `Read-S3Object` に対応付けられています。

```
PS > Set-Alias -Name Get-S3Content -Value Read-S3Object
```

エイリアスファイルは AWS Tools for PowerShell インストールディレクトリにあります。使用環境にエイリアスをロードするには、*ドットソース*形式でファイルを読み込みます。以下は、Windows ベースの例です。

```
PS > . "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowershell\AWSAliases.ps1"
```

Linux または macOS シェルの場合、次のようになります。

```
. ~/.local/share/powershell/Modules/AWSPowerShell.NetCore/3.3.563.1/AWSAliases.ps1
```

すべての AWS Tools for PowerShell エイリアスを表示するには、次のコマンドを実行します。このコマンドは、PowerShell `Where-Object` コマンドレットの `?` エイリアスと `Source` プロパティを使用して、`AWSPowerShell.NetCore` モジュールからのエイリアスのみをフィルタリングします。

```
PS > Get-Alias | ? Source -like "AWSPowerShell.NetCore"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Add-ASInstances                                    3.3.343.0  AWSPowerShell
Alias           Add-CTTag                                          3.3.343.0  AWSPowerShell
Alias           Add-DPTags                                         3.3.343.0  AWSPowerShell
Alias           Add-DSIpRoutes                                     3.3.343.0  AWSPowerShell
Alias           Add-ELBTags                                        3.3.343.0  AWSPowerShell
Alias           Add-EMRTag                                         3.3.343.0  AWSPowerShell
Alias           Add-ESTag                                          3.3.343.0  AWSPowerShell
Alias           Add-MLTag                                          3.3.343.0  AWSPowerShell
Alias           Clear-AWSCredentials                               3.3.343.0  AWSPowerShell
Alias           Clear-AWSDefaults                                  3.3.343.0  AWSPowerShell
Alias           Dismount-ASInstances                               3.3.343.0  AWSPowerShell
Alias           Edit-EC2Hosts                                      3.3.343.0  AWSPowerShell
Alias           Edit-RSClusterIamRoles                             3.3.343.0  AWSPowerShell
Alias           Enable-ORGAllFeatures                              3.3.343.0  AWSPowerShell
Alias           Find-CTEvents                                      3.3.343.0  AWSPowerShell
Alias           Get-ASACases                                       3.3.343.0  AWSPowerShell
Alias           Get-ASAccountLimits                                3.3.343.0  AWSPowerShell
Alias           Get-ASACommunications                              3.3.343.0  AWSPowerShell
Alias           Get-ASAServices                                    3.3.343.0  AWSPowerShell
Alias           Get-ASASeverityLevels                              3.3.343.0  AWSPowerShell
Alias           Get-ASATrustedAdvisorCheckRefreshStatuses          3.3.343.0  AWSPowerShell
Alias           Get-ASATrustedAdvisorChecks                        3.3.343.0  AWSPowerShell
Alias           Get-ASATrustedAdvisorCheckSummaries                3.3.343.0  AWSPowerShell
Alias           Get-ASLifecycleHooks                               3.3.343.0  AWSPowerShell
Alias           Get-ASLifecycleHookTypes                           3.3.343.0  AWSPowerShell
Alias           Get-AWSCredentials                                 3.3.343.0  AWSPowerShell
Alias           Get-CDApplications                                 3.3.343.0  AWSPowerShell
Alias           Get-CDDeployments                                  3.3.343.0  AWSPowerShell
Alias           Get-CFCloudFrontOriginAccessIdentities             3.3.343.0  AWSPowerShell
Alias           Get-CFDistributions                                3.3.343.0  AWSPowerShell
Alias           Get-CFGConfigRules                                 3.3.343.0  AWSPowerShell
Alias           Get-CFGConfigurationRecorders                      3.3.343.0  AWSPowerShell
Alias           Get-CFGDeliveryChannels                            3.3.343.0  AWSPowerShell
Alias           Get-CFInvalidations                                3.3.343.0  AWSPowerShell
Alias           Get-CFNAccountLimits                               3.3.343.0  AWSPowerShell
Alias           Get-CFNStackEvents                                 3.3.343.0  AWSPowerShell

...
```

このファイルに独自のエイリアスを追加するには、必要に応じて PowerShell の `$MaximumAliasCount` [ユーザー設定変数](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6)の値を 5500 より大きい値に引き上げます。デフォルト値は 4096 であり、これを最大 32768 まで引き上げることができます。これを行うには、次のコマンドを実行します。

```
PS > $MaximumAliasCount = 32768
```

変更が正常に行われたことを確認するには、変数名を入力して現在の値を表示します。

```
PS > $MaximumAliasCount
32768
```