Question about running DNSCmd.exe remotely using PSSession

Welcome Forums General PowerShell Q&A Question about running DNSCmd.exe remotely using PSSession

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

 
Member
4 years, 8 months ago.

  • Author
    Posts
  • #14460

    Participant
    Points: 21
    Rank: Member

    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 192.168.1.100
    
    Command failed:  ERROR_ACCESS_DENIED     5    0x5

    ——————————————–
    Performed on SERVER1 (Server 2012):

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

    Participant
    Points: 21
    Rank: Member

    Oh gosh. Please forgive my formatting.

  • #14473

    Member
    Points: 0
    Rank: Member

    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 https://powershell.org/ebooks/ ; there's a section on how you can get around that problem by enabling CredSSP.

The topic ‘Question about running DNSCmd.exe remotely using PSSession’ is closed to new replies.