Powershell 在所有正向查找区域中查询DNS服务器的特定IP地址?

Powershell 在所有正向查找区域中查询DNS服务器的特定IP地址?,powershell,dns,Powershell,Dns,我正在为100多个正向查找区域运行Windows Server DNS。 我需要找到,哪个正向查找区域或DNS条目正在使用特定的IP地址 因此,输入将是:192.0.2.4(任何IP地址) 结果:任何正向查找区域及其包含上述IP地址的DNS条目 这里的目标是查找由于旧IP地址而不再有效的DNS条目 一个不起作用的示例: Get-DnsServerResourceRecord -ZoneName * | Where-Object {$_.IPv4Address.IPAddressToString

我正在为100多个正向查找区域运行Windows Server DNS。 我需要找到,哪个正向查找区域或DNS条目正在使用特定的IP地址

因此,输入将是:
192.0.2.4
(任何IP地址) 结果:任何正向查找区域及其包含上述IP地址的DNS条目

这里的目标是查找由于旧IP地址而不再有效的DNS条目

一个不起作用的示例:

Get-DnsServerResourceRecord -ZoneName * | Where-Object {$_.IPv4Address.IPAddressToString -contains '192.0.2.4' }

您可以先查询您的区域,然后在其中循环:

$zones = Get-DnsServerZone | where {!$_.IsReverseLookupZone -and $_.ZoneType -eq 'Primary'}
foreach ($zone in $zones) {
    Get-DnsServerResourceRecord -ZoneName $zone.ZoneName |
        Where {$_.RecordData.Ipv4Address.IPAddressToString -contains '192.0.2.4'} |
            Select HostName,RecordType,Type,RecordData,Timestamp,TimeToLive,@{n='Zone';e={$zone.ZoneName}}
}
如果需要栅格视图,请使用
Out Gridview

$zones = Get-DnsServerZone | where {!$_.IsReverseLookupZone -and $_.ZoneType -eq 'Primary'}
$output = foreach ($zone in $zones) {
    Get-DnsServerResourceRecord -ZoneName $zone.ZoneName |
        Where {$_.RecordData.Ipv4Address.IPAddressToString -contains '192.0.2.4'} |
            Select HostName,RecordType,Type,RecordData,Timestamp,TimeToLive,@{n='Zone';e={$zone.ZoneName}}
}
$output | Out-GridView

伙计,谢谢你,你太棒了:-)我怎样才能将输出设置为Out GridView?@SeniorSystemsEngineer我使用
Out GridView