

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

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

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

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

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

**AWS CLI**  
**描述服务**  
以下 `describe-services` 示例检索默认集群中 `my-http-service` 服务的详细信息。  

```
aws ecs describe-services --services my-http-service
```
输出：  

```
{
    "services": [
        {
            "status": "ACTIVE",
            "taskDefinition": "arn:aws:ecs:us-west-2:123456789012:task-definition/amazon-ecs-sample:1",
            "pendingCount": 0,
            "loadBalancers": [],
            "desiredCount": 10,
            "createdAt": 1466801808.595,
            "serviceName": "my-http-service",
            "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/default",
            "serviceArn": "arn:aws:ecs:us-west-2:123456789012:service/my-http-service",
            "deployments": [
                {
                    "status": "PRIMARY",
                    "pendingCount": 0,
                    "createdAt": 1466801808.595,
                    "desiredCount": 10,
                    "taskDefinition": "arn:aws:ecs:us-west-2:123456789012:task-definition/amazon-ecs-sample:1",
                    "updatedAt": 1428326312.703,
                    "id": "ecs-svc/1234567890123456789",
                    "runningCount": 10
                }
            ],
            "events": [
                {
                    "message": "(service my-http-service) has reached a steady state.",
                    "id": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
                    "createdAt": 1466801812.435
                }
            ],
            "runningCount": 10
        }
    ],
    "failures": []
}
```
有关更多信息，请参阅《Amazon ECS 开发人员指南》**中的[服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeServices](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/describe-services.html)*中的。

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

**适用于 PowerShell V4 的工具**  
**示例 1：此示例演示如何从默认集群中检索特定服务的详细信息。**  

```
Get-ECSService -Service my-hhtp-service
```
**示例 2：此示例演示如何检索在指定集群中运行的特定服务的详细信息。**  

```
Get-ECSService -Cluster myCluster -Service my-hhtp-service
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [DescribeServices](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例演示如何从默认集群中检索特定服务的详细信息。**  

```
Get-ECSService -Service my-hhtp-service
```
**示例 2：此示例演示如何检索在指定集群中运行的特定服务的详细信息。**  

```
Get-ECSService -Cluster myCluster -Service my-hhtp-service
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeServices](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------