Get-DnsServerResourceRecord filter records

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 blah.com -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 blah.com -ComputerName . -Name $dns[0].ComputerName | ? {$_.recorddata.ipv4address -like “10.10.10.10”}

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!

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.