

のバージョン 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)

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

# AWS Cloud9 Tools for PowerShell V5 を使用した の例
<a name="powershell_cloud9_code_examples"></a>

次のコード例は、 で AWS Tools for PowerShell V5 を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています AWS Cloud9。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。

**Topics**
+ [アクション](#actions)

## アクション
<a name="actions"></a>

### `Get-C9EnvironmentData`
<a name="cloud9_DescribeEnvironments_powershell_topic"></a>

次のコード例は、`Get-C9EnvironmentData` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された AWS Cloud9 開発環境に関する情報を取得します。**  

```
Get-C9EnvironmentData -EnvironmentId 685f892f431b45c2b28cb69eadcdb0EX,1980b80e5f584920801c09086667f0EX
```
**出力:**  

```
Arn         : arn:aws:cloud9:us-east-1:123456789012:environment:685f892f431b45c2b28cb69eadcdb0EX
Description : Created from CodeStar.
Id          : 685f892f431b45c2b28cb69eadcdb0EX
Lifecycle   : Amazon.Cloud9.Model.EnvironmentLifecycle
Name        : my-demo-ec2-env
OwnerArn    : arn:aws:iam::123456789012:user/MyDemoUser
Type        : ec2

Arn         : arn:aws:cloud9:us-east-1:123456789012:environment:1980b80e5f584920801c09086667f0EX
Description :
Id          : 1980b80e5f584920801c09086667f0EX
Lifecycle   : Amazon.Cloud9.Model.EnvironmentLifecycle
Name        : my-demo-ssh-env
OwnerArn    : arn:aws:iam::123456789012:user/MyDemoUser
Type        : ssh
```
**例 2: この例では、指定された AWS Cloud9 開発環境のライフサイクルステータスに関する情報を取得します。**  

```
(Get-C9EnvironmentData -EnvironmentId 685f892f431b45c2b28cb69eadcdb0EX).Lifecycle
```
**出力:**  

```
FailureResource Reason Status
--------------- ------ ------
                       CREATED
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[DescribeEnvironments](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Get-C9EnvironmentList`
<a name="cloud9_ListEnvironments_powershell_topic"></a>

次のコード例は、`Get-C9EnvironmentList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、使用可能な AWS Cloud9 開発環境識別子のリストを取得します。**  

```
Get-C9EnvironmentList
```
**出力:**  

```
685f892f431b45c2b28cb69eadcdb0EX
1980b80e5f584920801c09086667f0EX
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[ListEnvironments](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Get-C9EnvironmentMembershipList`
<a name="cloud9_DescribeEnvironmentMemberships_powershell_topic"></a>

次のコード例は、`Get-C9EnvironmentMembershipList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された AWS Cloud9 開発環境の環境メンバーに関する情報を取得します。**  

```
Get-C9EnvironmentMembershipList -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX
```
**出力:**  

```
EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX
LastAccess    : 1/1/0001 12:00:00 AM
Permissions   : read-write
UserArn       : arn:aws:iam::123456789012:user/AnotherDemoUser
UserId        : AIDAJ3BA6O2FMJWCWXHEX

EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX
LastAccess    : 1/1/0001 12:00:00 AM
Permissions   : owner
UserArn       : arn:aws:iam::123456789012:user/MyDemoUser
UserId        : AIDAJ3LOROMOUXTBSU6EX
```
**例 2: この例では、指定された AWS Cloud9 開発環境の所有者に関する情報を取得します。**  

```
Get-C9EnvironmentMembershipList -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Permission owner
```
**出力:**  

```
EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX
LastAccess    : 1/1/0001 12:00:00 AM
Permissions   : owner
UserArn       : arn:aws:iam::123456789012:user/MyDemoUser
UserId        : AIDAJ3LOROMOUXTBSU6EX
```
**例 3: この例では、multiple AWS Cloud9 開発環境の指定された環境メンバーに関する情報を取得します。**  

```
Get-C9EnvironmentMembershipList -UserArn arn:aws:iam::123456789012:user/MyDemoUser
```
**出力:**  

```
EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX
LastAccess    : 1/17/2018 7:48:14 PM
Permissions   : owner
UserArn       : arn:aws:iam::123456789012:user/MyDemoUser
UserId        : AIDAJ3LOROMOUXTBSU6EX

EnvironmentId : 1980b80e5f584920801c09086667f0EX
LastAccess    : 1/16/2018 11:21:24 PM
Permissions   : owner
UserArn       : arn:aws:iam::123456789012:user/MyDemoUser
UserId        : AIDAJ3LOROMOUXTBSU6EX
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[DescribeEnvironmentMemberships](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Get-C9EnvironmentStatus`
<a name="cloud9_DescribeEnvironmentStatus_powershell_topic"></a>

次のコード例は、`Get-C9EnvironmentStatus` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された AWS Cloud9 開発環境のステータス情報を取得します。**  

```
Get-C9EnvironmentStatus -EnvironmentId 349c86d4579e4e7298d500ff57a6b2EX
```
**出力:**  

```
Message                     Status
-------                     ------
Environment is ready to use ready
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[DescribeEnvironmentStatus](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `New-C9EnvironmentEC2`
<a name="cloud9_CreateEnvironmentEc2_powershell_topic"></a>

次のコード例は、`New-C9EnvironmentEC2` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された設定で AWS Cloud9 開発環境を作成し、Amazon Elastic Compute Cloud (Amazon EC2) インスタンスを起動してから、インスタンスから環境に接続します。**  

```
New-C9EnvironmentEC2 -Name my-demo-env -AutomaticStopTimeMinutes 60 -Description "My demonstration development environment." -InstanceType t2.micro -OwnerArn arn:aws:iam::123456789012:user/MyDemoUser -SubnetId subnet-d43a46EX
```
**出力:**  

```
ffd88420d4824eeeaeaa8a04bfde8cEX
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[CreateEnvironmentEc2](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `New-C9EnvironmentMembership`
<a name="cloud9_CreateEnvironmentMembership_powershell_topic"></a>

次のコード例は、`New-C9EnvironmentMembership` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された環境メンバーを指定された AWS Cloud9 開発環境に追加します。**  

```
New-C9EnvironmentMembership -UserArn arn:aws:iam::123456789012:user/AnotherDemoUser -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Permission read-write
```
**出力:**  

```
EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX
LastAccess    : 1/1/0001 12:00:00 AM
Permissions   : read-write
UserArn       : arn:aws:iam::123456789012:user/AnotherDemoUser
UserId        : AIDAJ3BA6O2FMJWCWXHEX
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[CreateEnvironmentMembership](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Remove-C9Environment`
<a name="cloud9_DeleteEnvironment_powershell_topic"></a>

次のコード例は、`Remove-C9Environment` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された AWS Cloud9 開発環境を削除します。環境が Amazon EC2 インスタンスに接続されている場合、インスタンスも終了します。**  

```
Remove-C9Environment -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[DeleteEnvironment](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Remove-C9EnvironmentMembership`
<a name="cloud9_DeleteEnvironmentMembership_powershell_topic"></a>

次のコード例は、`Remove-C9EnvironmentMembership` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された AWS Cloud9 開発環境から指定された環境メンバーを削除します。**  

```
Remove-C9EnvironmentMembership -UserArn arn:aws:iam::123456789012:user/AnotherDemoUser -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[DeleteEnvironmentMembership](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Update-C9Environment`
<a name="cloud9_UpdateEnvironment_powershell_topic"></a>

次のコード例は、`Update-C9Environment` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された既存の AWS Cloud9 開発環境の指定された設定を変更します。**  

```
Update-C9Environment -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Description "My changed demonstration development environment." -Name my-changed-demo-env
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[UpdateEnvironment](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Update-C9EnvironmentMembership`
<a name="cloud9_UpdateEnvironmentMembership_powershell_topic"></a>

次のコード例は、`Update-C9EnvironmentMembership` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された AWS Cloud9 開発環境の指定された既存の環境メンバーの設定を変更します。**  

```
Update-C9EnvironmentMembership -UserArn arn:aws:iam::123456789012:user/AnotherDemoUser -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Permission read-only
```
**出力:**  

```
EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX
LastAccess    : 1/1/0001 12:00:00 AM
Permissions   : read-only
UserArn       : arn:aws:iam::123456789012:user/AnotherDemoUser
UserId        : AIDAJ3BA6O2FMJWCWXHEX
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[UpdateEnvironmentMembership](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。