

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 搭配使用 `ListDeploymentInstances` 與 CLI
<a name="codedeploy_example_codedeploy_ListDeploymentInstances_section"></a>

下列程式碼範例示範如何使用 `ListDeploymentInstances`。

------
#### [ CLI ]

**AWS CLI**  
**取得部署執行個體的相關資訊**  
下列 `list-deployment-instances` 範例顯示與指定之部署相關聯的所有部署執行個體相關資訊。  

```
aws deploy list-deployment-instances \
    --deployment-id d-A1B2C3111 \
    --instance-status-filter Succeeded
```
輸出：  

```
{
    "instancesList": [
        "i-EXAMPLE11",
        "i-EXAMPLE22"
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListDeploymentInstances](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/deploy/list-deployment-instances.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：此範例會取得指定之部署的執行個體 ID 清單。**  

```
Get-CDDeploymentInstanceList -DeploymentId d-QZMRGSTEX
```
**輸出：**  

```
i-254e22EX
i-274e22EX
i-3b4e22EX
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [ListDeploymentInstances](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此範例會取得指定之部署的執行個體 ID 清單。**  

```
Get-CDDeploymentInstanceList -DeploymentId d-QZMRGSTEX
```
**輸出：**  

```
i-254e22EX
i-274e22EX
i-3b4e22EX
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [ListDeploymentInstances](https://docs.aws.amazon.com/powershell/v5/reference)。

------