Author Posts

October 19, 2017 at 8:00 pm

Hi guys,

Today I was trying to search DNS records filtered by CSV file in which I had computername and IP address.

So the command was:
$dns=import-csv dns.csv

Get-DnsServerResourceRecord -ZoneName -ComputerName . -Name $dns[0].ComputerName | ? {$_.recorddata.ipv4address -like $dns[0].IP} – which gave me no results, but when i hardcoded ip address i got the results, for example :

Get-DnsServerResourceRecord -ZoneName -ComputerName . -Name $dns[0].ComputerName | ? {$_.recorddata.ipv4address -like ""}

Could you figure out where is the problem? I guess is in types of properties as the recorddata.ipv4address is ciminstance type while $dns[0].ip is string type.

Many thanks!

October 19, 2017 at 8:23 pm

yeah it could be the type mismatch. You should be able to add .ToString() on the end of $_.recorddata.ipv4address, that should then have you comparing two strings.