

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

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

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

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

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

**AWS CLI**  
**获取跟踪的状态**  
以下 `get-trail-status` 命令返回 `Trail1` 的交付和日志记录的详细信息：  

```
aws cloudtrail get-trail-status --name Trail1
```
输出：  

```
{
  "LatestNotificationTime": 1454022144.869,
  "LatestNotificationAttemptSucceeded": "2016-01-28T23:02:24Z",
  "LatestDeliveryAttemptTime": "2016-01-28T23:02:24Z",
  "LatestDeliveryTime": 1454022144.869,
  "TimeLoggingStarted": "2015-11-06T18:36:38Z",
  "LatestDeliveryAttemptSucceeded": "2016-01-28T23:02:24Z",
  "IsLogging": true,
  "LatestCloudWatchLogsDeliveryTime": 1454022144.918,
  "StartLoggingTime": 1446834998.695,
  "StopLoggingTime": 1446834996.933,
  "LatestNotificationAttemptTime": "2016-01-28T23:02:24Z",
  "TimeLoggingStopped": "2015-11-06T18:36:36Z"
}
```
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetTrailStatus](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudtrail/get-trail-status.html)*中的。

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

**适用于 PowerShell V4 的工具**  
**示例 1：返回名为 “myExampleTrail” 的跟踪的状态信息。返回的数据包括有关传输错误、Amazon SNS 和 Amazon S3 错误以及跟踪的开始和停止日志记录时间的信息。此示例假设跟踪是在与当前 Shell 默认区域相同的区域中创建的。**  

```
Get-CTTrailStatus -Name myExampleTrail
```
**示例 2：返回在当前 Shell 默认区域以外的区域 [在本例中为法兰克福（eu-central-1）区域] 中创建的跟踪的状态信息。**  

```
Get-CTTrailStatus -Name myExampleTrail -Region eu-central-1
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [GetTrailStatus](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：返回名为 “myExampleTrail” 的跟踪的状态信息。返回的数据包括有关传输错误、Amazon SNS 和 Amazon S3 错误以及跟踪的开始和停止日志记录时间的信息。此示例假设跟踪是在与当前 Shell 默认区域相同的区域中创建的。**  

```
Get-CTTrailStatus -Name myExampleTrail
```
**示例 2：返回在当前 Shell 默认区域以外的区域 [在本例中为法兰克福（eu-central-1）区域] 中创建的跟踪的状态信息。**  

```
Get-CTTrailStatus -Name myExampleTrail -Region eu-central-1
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [GetTrailStatus](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------