

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

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

# 搭配使用 `GetOnPremisesInstance` 與 CLI
<a name="codedeploy_example_codedeploy_GetOnPremisesInstance_section"></a>

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

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

**AWS CLI**  
**取得內部部署執行個體的相關資訊**  
以下 `get-on-premises-instance` 範例擷取指定之內部部署執行個體的相關資訊。  

```
aws deploy get-on-premises-instance --instance-name AssetTag12010298EX
```
輸出：  

```
{
    "instanceInfo": {
    "iamUserArn": "arn:aws:iam::123456789012:user/AWS/CodeDeploy/AssetTag12010298EX",
        "tags": [
        {
            "Value": "CodeDeployDemo-OnPrem",
            "Key": "Name"
        }
        ],
        "instanceName": "AssetTag12010298EX",
        "registerTime": 1425579465.228,
        "instanceArn": "arn:aws:codedeploy:us-east-1:123456789012:instance/AssetTag12010298EX_4IwLNI2Alh"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetOnPremisesInstance](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/deploy/get-on-premises-instance.html)。

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

**Tools for PowerShell V4**  
**範例 1：此範例會取得指定之內部部署執行個體的相關資訊。**  

```
Get-CDOnPremiseInstance -InstanceName AssetTag12010298EX
```
**輸出：**  

```
DeregisterTime : 1/1/0001 12:00:00 AM
IamUserArn     : arn:aws:iam::80398EXAMPLE:user/CodeDeployDemoUser
InstanceArn    : arn:aws:codedeploy:us-east-1:80398EXAMPLE:instance/AssetTag12010298EX_rDH556dxEX
InstanceName   : AssetTag12010298EX
RegisterTime   : 4/3/2015 6:36:24 PM
Tags           : {Name}
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [GetOnPremisesInstance](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此範例會取得指定之內部部署執行個體的相關資訊。**  

```
Get-CDOnPremiseInstance -InstanceName AssetTag12010298EX
```
**輸出：**  

```
DeregisterTime : 1/1/0001 12:00:00 AM
IamUserArn     : arn:aws:iam::80398EXAMPLE:user/CodeDeployDemoUser
InstanceArn    : arn:aws:codedeploy:us-east-1:80398EXAMPLE:instance/AssetTag12010298EX_rDH556dxEX
InstanceName   : AssetTag12010298EX
RegisterTime   : 4/3/2015 6:36:24 PM
Tags           : {Name}
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [GetOnPremisesInstance](https://docs.aws.amazon.com/powershell/v5/reference)。

------