Question about running DNSCmd.exe remotely using PSSession

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.

Oh gosh. Please forgive my formatting.

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.