

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

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

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

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

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

**AWS CLI**  
**获取有关实例配置文件的信息**  
以下 `get-instance-profile` 命令可获取名为 `ExampleInstanceProfile` 的实例配置文件的信息。  

```
aws iam get-instance-profile \
    --instance-profile-name ExampleInstanceProfile
```
输出：  

```
{
    "InstanceProfile": {
        "InstanceProfileId": "AID2MAB8DPLSRHEXAMPLE",
        "Roles": [
            {
                "AssumeRolePolicyDocument": "<URL-encoded-JSON>",
                "RoleId": "AIDGPMS9RO4H3FEXAMPLE",
                "CreateDate": "2013-01-09T06:33:26Z",
                "RoleName": "Test-Role",
                "Path": "/",
                "Arn": "arn:aws:iam::336924118301:role/Test-Role"
            }
        ],
        "CreateDate": "2013-06-12T23:52:02Z",
        "InstanceProfileName": "ExampleInstanceProfile",
        "Path": "/",
        "Arn": "arn:aws:iam::336924118301:instance-profile/ExampleInstanceProfile"
    }
}
```
有关更多信息，请参阅《AWS IAM 用户指南》**中的[使用实例配置文件](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetInstanceProfile](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/get-instance-profile.html)*中的。

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

**适用于 PowerShell V4 的工具**  
**示例 1：此示例返回当前 AWS 账户中定义`ec2instancerole`的名为的实例配置文件的详细信息。**  

```
Get-IAMInstanceProfile -InstanceProfileName ec2instancerole
```
**输出**：  

```
Arn                 : arn:aws:iam::123456789012:instance-profile/ec2instancerole
CreateDate          : 2/17/2015 2:49:04 PM
InstanceProfileId   : HH36PTZQJUR32EXAMPLE1
InstanceProfileName : ec2instancerole
Path                : /
Roles               : {ec2instancerole}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [GetInstanceProfile](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例返回当前 AWS 账户中定义`ec2instancerole`的名为的实例配置文件的详细信息。**  

```
Get-IAMInstanceProfile -InstanceProfileName ec2instancerole
```
**输出**：  

```
Arn                 : arn:aws:iam::123456789012:instance-profile/ec2instancerole
CreateDate          : 2/17/2015 2:49:04 PM
InstanceProfileId   : HH36PTZQJUR32EXAMPLE1
InstanceProfileName : ec2instancerole
Path                : /
Roles               : {ec2instancerole}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [GetInstanceProfile](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------