Get-DnsServerResourceRecord fails on DNS server

Welcome Forums General PowerShell Q&A Get-DnsServerResourceRecord fails on DNS server

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

 
Participant
3 months, 2 weeks ago.

  • Author
    Posts
  • #103753

    Participant
    Points: 0
    Rank: Member

    I try running basic record lookup directly on a Windows server 2012 R2 DC as such:

    Get-DnsServerResourceRecord -ZoneName 'mycorp.com' -ComputerName lvsp01rwt002.mycorp.com

    and get error:

    Get-DnsServerResourceRecord : Failed to get the zone information for mycorp.com on server lvsp01rwt002.mycorp.com.

    I know the Zone exists and the record does exist as well. Why is this DNS cmdlet failing to retrieve the info?

    Thanks

  • #103756

    Participant
    Points: 8
    Rank: Member

    You might have misunderstood the syntax for this cmdlet. If I got you right you meant something like this:

    Get-DnsServerResourceRecord -ZoneName 'mycorp.com' |
        Where-Object {$_.HostName -like '*lvsp01rwt002.mycorp.com*'}
    • #103760

      Participant
      Points: 0
      Rank: Member

      I actually just copied the code out of Richard Siddaway's book AD Management in a Month of Lunches

      It's on page 214 section 15.3.1

    • #103765

      Participant
      Points: 8
      Rank: Member

      I don't know what to say. I don't have the book. Did you try it? Did it work?

  • #103763

    Participant
    Points: 0
    Rank: Member

    Jeff,

    The -ComputerName parameter on this cmdlet is looking for the name of your DNS server. Perhaps you are supplying the name of the record you are searching for? Try something like this

    $splat = @{
    Name = 'hostname'
    ComputerName = 'DNSserverName'
    zoneName = 'ZoneName'
    }
    
    Get-DnsServerResourceRecord @splat
    
  • #103766

    Participant
    Points: 0
    Rank: Member

    Thanks for the catch L-bo. To be fair, on the next page Siddaway does state that the -ComputerName parameter is indeed the name of the DNS server. I changed my test one liner, as well as ran your snippet of code and both work.

    thanks again.

  • #103769

    Participant
    Points: 0
    Rank: Member

    Hey Jeff, Just to add here. Whenever the cmdlet you are running gives you an error like this, look in the inbuilt help system for PowerShell. If you haven't done so already run an elevated PowerShell prompt and run Update-Help. This will grab any help the system can find for any modules you have on your system that have updateable help.

    Once that is done run Help

    help Get-DnsServerResourceRecord -ShowWindow

    this will pop open a separate window with the full help for that cmdlet, parameters and what each param does and more importantly its examples.

  • #103780

    Participant
    Points: 0
    Rank: Member

    Glad you got it resolved. I was sure the example worked 🙂

    • #103834

      Participant
      Points: 0
      Rank: Member

      Thanks Richard. Love your work

The topic ‘Get-DnsServerResourceRecord fails on DNS server’ is closed to new replies.