

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将 `ListOnPremisesInstances` 与 CLI 配合使用
<a name="codedeploy_example_codedeploy_ListOnPremisesInstances_section"></a>

以下代码示例演示如何使用 `ListOnPremisesInstances`。

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

**AWS CLI**  
**获取有关一个或多个本地实例的信息**  
以下`list-on-premises-instances`示例检索在中注册的实例的可用本地实例名称列表，这些实例还具有 AWS CodeDeploy 与该实例关联的 AWS CodeDeploy 指定本地实例标签。  

```
aws deploy list-on-premises-instances \
    --registration-status Registered \
    --tag-filters Key=Name,Value=CodeDeployDemo-OnPrem,Type=KEY_AND_VALUE
```
输出：  

```
{
    "instanceNames": [
        "AssetTag12010298EX"
    ]
}
```
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListOnPremisesInstances](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/deploy/list-on-premises-instances.html)*中的。

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

**适用于 PowerShell V4 的工具**  
**示例 1：此示例获取可用本地实例名称的列表。**  

```
Get-CDOnPremiseInstanceList
```
**输出**：  

```
AssetTag12010298EX
AssetTag12010298EX-2
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [ListOnPremisesInstances](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取可用本地实例名称的列表。**  

```
Get-CDOnPremiseInstanceList
```
**输出**：  

```
AssetTag12010298EX
AssetTag12010298EX-2
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ListOnPremisesInstances](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------