Want all DC's resource records from DNS

Welcome Forums General PowerShell Q&A Want all DC's resource records from DNS

This topic contains 5 replies, has 3 voices, and was last updated by

Jon
 
Participant
1 month ago.

  • Author
    Posts
  • #112042

    Participant
    Points: 0
    Rank: Member

    I have this one liner:

    Get-DnsServerResourceRecord -ZoneName "dev.corp.com" -RRType Srv | Where-Object {$_.RecordType -contains "SRV"}

    ...and I get all SRV records fine, but i want to winnow down to a specific host, so tried this:

    Get-DnsServerResourceRecord -ZoneName "dev.corp.com" -RRType Srv | Where-Object {$_.RecordData -contains "DC_008"}

    I tried

    Get-DnsServerResourceRecord -ZoneName "dev.corp.com" -RRType Srv | gm

    ..to discover a MemberType Property of "RecordData" but coming up empty.

    How should I define my Where-Object?

    thank you.

  • #112043

    Participant
    Points: 0
    Rank: Member

    The RecordData object has a DomainName property.  Try this:

    Get-DnsServerResourceRecord -ZoneName "dev.corp.com" -RRType Srv | Where-Object {$_.RecordData.DomainName
    -like '*DC_008*'}

     

    • #112048

      Participant
      Points: 0
      Rank: Member

      Thanks Matt,

      Helping myself, how do I find a given object's additional properties, if not with Get-Member?

  • #112051

    Participant
    Points: 0
    Rank: Member

    I used Get-Member but expanded the property:

     Get-DnsServerResourceRecord -ZoneName "contoso.com" -RRType Srv | Select -expandproperty Recorddata | Get-Member 
  • #112052

    Participant
    Points: 0
    Rank: Member

    fantastic, thank you very much

  • #112082
    Jon

    Participant
    Points: 2
    Rank: Member

    I'm lazy and I like to do it like this. One of the many great things about PS, many ways to accomplish the same task!

    
    (Get-DnsServerResourceRecord -ZoneName "domain.local" -RRType srv).recorddata | GM
    
    

You must be logged in to reply to this topic.