# Question about running DNSCmd.exe remotely using PSSession

**URL:** <https://forums.powershell.org/t/question-about-running-dnscmd-exe-remotely-using-pssession/2441>\
**Category:** PowerShell Help\
**Created:** [April 10, 2014, 6:59am UTC](https://forums.powershell.org/t/question-about-running-dnscmd-exe-remotely-using-pssession/2441 "2014-04-10T06:59:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris-stella-84](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@chris-stella-84](https://forums.powershell.org/u/chris-stella-84)\
**Post date:** [April 10, 2014, 6:59am UTC](https://forums.powershell.org/t/question-about-running-dnscmd-exe-remotely-using-pssession/2441/1 "2014-04-10T06:59:51Z")

</div>

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):

```auto
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):

```auto
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.﻿

```

---

<div class="post-metadata">

**Author:** ![chris-stella-84](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@chris-stella-84](https://forums.powershell.org/u/chris-stella-84)\
**Post date:** [April 10, 2014, 7:03am UTC](https://forums.powershell.org/t/question-about-running-dnscmd-exe-remotely-using-pssession/2441/2 "2014-04-10T07:03:32Z")

</div>

Oh gosh. Please forgive my formatting.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 10, 2014, 11:41am UTC](https://forums.powershell.org/t/question-about-running-dnscmd-exe-remotely-using-pssession/2441/3 "2014-04-10T11:41:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:52pm UTC](https://forums.powershell.org/t/question-about-running-dnscmd-exe-remotely-using-pssession/2441/4 "2024-05-16T20:52:10Z")

</div>


