Question about running DNSCmd.exe remotely using PSSession

This topic contains 2 replies, has 2 voices, and was last updated by  Dave Wyatt 4 years, 2 months ago.

  • Author
  • #14460

    Chris Stella

    Help! I'm fairly new to PowerShell so bear with me if this is an obvious fix, but I haven't found an answer yet. I'm trying to use the DNSCmd.exe command to add a DNS entry on a remote computer. I'm using PowerShell to run the command remotely using PSSession.

    The issue is, I get the REMOTE_ACCESS_DENIED error from DNSCmd.exe when I run the command remotely with PowerShell, but it works if I'm actually logged into the remote computer and run the command locally using the same credentials.

    Attempting via PSSession (From Win 8):

    PS D:\> Enter-PSSession -Credential $creds SERVER1
    [SERVER1]: PS C:\windows\system32> dnscmd.exe DNSSERVER /recordadd ZONE dnstest1008 A
    Command failed:  ERROR_ACCESS_DENIED     5    0x5

    Performed on SERVER1 (Server 2012):

    PS C:\windows\system32> dnscmd.exe DNSSERVER /recordadd ZONE dnstest1008 A
    Add A Record for dnstest1008.ZONE at ZONE
    Command completed successfully.
  • #14461

    Chris Stella

    Oh gosh. Please forgive my formatting.

  • #14473

    Dave Wyatt

    Looks like you're running into the "second hop" issue there, trying to access another remote server via a PSSession. Check out the "Secrets of PowerShell Remoting" ebook from ; there's a section on how you can get around that problem by enabling CredSSP.

You must be logged in to reply to this topic.