

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

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

# 搭配使用 `GetBucketInventoryConfiguration` 與 CLI
<a name="s3_example_s3_GetBucketInventoryConfiguration_section"></a>

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

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

**AWS CLI**  
**擷取儲存貯體的庫存組態**  
下列 `get-bucket-inventory-configuration` 範例會擷取 ID 為 `1` 之指定儲存貯體的庫存組態。  

```
aws s3api get-bucket-inventory-configuration \
    --bucket amzn-s3-demo-bucket \
    --id 1
```
輸出：  

```
{
    "InventoryConfiguration": {
        "IsEnabled": true,
        "Destination": {
            "S3BucketDestination": {
                "Format": "ORC",
                "Bucket": "arn:aws:s3:::amzn-s3-demo-bucket",
                "AccountId": "123456789012"
            }
        },
        "IncludedObjectVersions": "Current",
        "Id": "1",
        "Schedule": {
            "Frequency": "Weekly"
        }
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetBucketInventoryConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/get-bucket-inventory-configuration.html)。

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

**Tools for PowerShell V4**  
**範例 1：此命令會傳回給定 S3 儲存貯體之名為 'testinventory' 的庫存詳細資訊。**  

```
Get-S3BucketInventoryConfiguration -BucketName 'amzn-s3-demo-bucket' -InventoryId 'testinventory'
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [GetBucketInventoryConfiguration](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此命令會傳回給定 S3 儲存貯體之名為 'testinventory' 的庫存詳細資訊。**  

```
Get-S3BucketInventoryConfiguration -BucketName 'amzn-s3-demo-bucket' -InventoryId 'testinventory'
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [GetBucketInventoryConfiguration](https://docs.aws.amazon.com/powershell/v5/reference)。

------