

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

# 搭配使用 `ListHostedZonesByName` 與 CLI
<a name="route-53_example_route-53_ListHostedZonesByName_section"></a>

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

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

**AWS CLI**  
下列命令會列出最多 100 個依網域名稱排序的託管區域：  

```
aws route53 list-hosted-zones-by-name
```
輸出：  

```
{
  "HostedZones": [
      {
          "ResourceRecordSetCount": 2,
          "CallerReference": "test20150527-2",
          "Config": {
              "Comment": "test2",
              "PrivateZone": false
          },
          "Id": "/hostedzone/Z119WBBTVP5WFX",
          "Name": "2.example.com."
      },
      {
          "ResourceRecordSetCount": 2,
          "CallerReference": "test20150527-1",
          "Config": {
              "Comment": "test",
              "PrivateZone": false
          },
          "Id": "/hostedzone/Z3P5QSUBK4POTI",
          "Name": "www.example.com."
      }
  ],
  "IsTruncated": false,
  "MaxItems": "100"
}
```
下列命令會列出依名稱排序的託管區域，開頭為 `www.example.com`：  

```
aws route53 list-hosted-zones-by-name --dns-name www.example.com
```
輸出：  

```
{
  "HostedZones": [
      {
          "ResourceRecordSetCount": 2,
          "CallerReference": "mwunderl20150527-1",
          "Config": {
              "Comment": "test",
              "PrivateZone": false
          },
          "Id": "/hostedzone/Z3P5QSUBK4POTI",
          "Name": "www.example.com."
      }
  ],
  "DNSName": "www.example.com",
  "IsTruncated": false,
  "MaxItems": "100"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListHostedZonesByName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/route53/list-hosted-zones-by-name.html)。

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

**Tools for PowerShell V4**  
**範例 1：依網域名稱，以 ASCII 順序傳回所有公有和私有託管區域。**  

```
Get-R53HostedZonesByName
```
**範例 2：依網域名稱，以 ASCII 順序傳回公有和私有託管區域，從指定的 DNS 名稱開始。**  

```
Get-R53HostedZonesByName -DnsName example2.com
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [ListHostedZonesByName](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：依網域名稱，以 ASCII 順序傳回所有公有和私有託管區域。**  

```
Get-R53HostedZonesByName
```
**範例 2：依網域名稱，以 ASCII 順序傳回公有和私有託管區域，從指定的 DNS 名稱開始。**  

```
Get-R53HostedZonesByName -DnsName example2.com
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [ListHostedZonesByName](https://docs.aws.amazon.com/powershell/v5/reference)。

------

如需 AWS SDK 開發人員指南和程式碼範例的完整清單，請參閱 [搭配 AWS SDK 使用 Route 53](sdk-general-information-section.md)。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。