尝试从DNS获取ZoneName时出错

时间:2017-07-06 10:53:23

标签: powershell powershell-v3.0 windows-server-2008-r2

尝试从DNS获取ZoneName时出现错误。

$zoneNames = (Get-DnsServerZone | Where-Object {
    $_.IsReverseLookupZone -eq $true
}).ZoneName

错误讯息:

  

术语“Get-DnsServerZone”未被识别为cmdlet,函数,脚本文件或可操作程序的名称。

1 个答案:

答案 0 :(得分:2)

如评论中所述,包含DnsServer cmdlet的Get-DnsServerZone模块随Windows Server 2012及更高版本一起提供。

在2008 R2上,您必须使用dnscmd或查询目标DNS服务器上的MicrosoftDNS WMI命名空间:

$ZoneNames = (Get-WmiObject -Namespace root\MicrosoftDNS -Class MicrosoftDNS_Zone -Filter 'Reverse = true' -ComputerName targetdnsserver.domain.tld).Name