Get-DnsServerResourceRecord filter records

Welcome Forums General PowerShell Q&A Get-DnsServerResourceRecord filter records

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
1 year ago.

  • Author
    Posts
  • #82544

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 1
    Rank: Member

    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.

The topic ‘Get-DnsServerResourceRecord filter records’ is closed to new replies.