Get-DnsServerResourceRecord fails on DNS server

This topic contains 8 replies, has 5 voices, and was last updated by  Jeff Taylor 2 weeks, 2 days ago.

  • Author
    Posts
  • #103753

    Jeff Taylor
    Participant

    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

    Olaf Soyk
    Participant

    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

      Jeff Taylor
      Participant

      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

      Olaf Soyk
      Participant

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

  • #103763

    L-Bo
    Participant

    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

    Jeff Taylor
    Participant

    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

    Alex Aymonier
    Participant

    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

    Richard Siddaway
    Moderator

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

You must be logged in to reply to this topic.