

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

# 将 `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 ]

**适用于 PowerShell V4 的工具**  
**示例 1：按照域名以 ASCII 顺序返回所有公有和私有托管区。**  

```
Get-R53HostedZonesByName
```
**示例 2：按照域名以 ASCII 顺序返回公有和私有托管区，开头为指定的 DNS 名称。**  

```
Get-R53HostedZonesByName -DnsName example2.com
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [ListHostedZonesByName](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：按照域名以 ASCII 顺序返回所有公有和私有托管区。**  

```
Get-R53HostedZonesByName
```
**示例 2：按照域名以 ASCII 顺序返回公有和私有托管区，开头为指定的 DNS 名称。**  

```
Get-R53HostedZonesByName -DnsName example2.com
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ListHostedZonesByName](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------

有关 S AWS DK 开发者指南和代码示例的完整列表，请参阅[将 Route 53 与 S AWS DK 一起使用](sdk-general-information-section.md)。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。