Get-DnsServerResourceRecord filter records

This topic contains 1 reply, has 2 voices, and was last updated by  Jeremy Murrah 1 month ago.

  • Author
    Posts
  • #82544

    Dorian
    Participant

    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!

  • #82555

    Jeremy Murrah
    Participant

    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.

You must be logged in to reply to this topic.