Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Am at a complete loss with this one. Recently a number of my powershell scripts have started failing as they are unable to find the command dnscmd.exe.

What has me at a loss is that the executable exists and works and I can run it just fine in the command prompt. I have tried the following in powershell to run the command:

  • dnscmd
  • & dnscmd
  • & dnscmd.exe
  • & c:\windows\system32\dnscmd.exe

All return "The term dnscmd is not recognized as the name of a cmdlet, function,script file or operable program...."

Can anyone enlighten me as to why powershell is completely unable to see the command, where the normal command prompt/windows explorer etc.. can? Using powershell 2.

share|improve this question
1  
are you sure that you have the dns admin tools loaded on "this" particular workstation/server? –  tony roth Jun 28 '10 at 20:24
    
Yep, I can confirm the admin tools are installed. I run them just fine from the command prompt on the same machine. –  Ben Short Jun 28 '10 at 22:53
    
My issue was that I ran it on a DC that I had not promoted yet. No DNS tools. –  Mike Christiansen Jul 1 at 10:19

5 Answers 5

up vote 3 down vote accepted

This sounds like the work of the File System Redirector to me. Are you running on a 64bit OS?

For example, when you make a call to C:\Windows\system32\dnscmd.exe on a 64bit OS using PowerShell (x86), this will be redirected to C:\Windows\SysWow64\dnscmd.exe. The redirection occurs at the point the folder is accessed so even though you are explicitly providing the path to the executable, you'll still be diverted. This can be disabled on the current thread via calls to native Windows APIs or can be avoided through the use of certain variables and aliases.

More information here: http://msdn.microsoft.com/en-us/library/aa384187%28VS.85%29.aspx

share|improve this answer

What do you get when you execute:

Get-Command dnscmd.exe -CommandType Application

share|improve this answer
    
Get-Command : The term 'dnscmd.exe' is not recognized as the name of a cmdlet, function, script file, or operable progr am. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. –  Ben Short Jun 28 '10 at 22:52
    
Just a link to a screenshot - dl.dropbox.com/u/8408796/dnscmd.JPG Confirmed that c:\windows\system32\ is in the powershell path. –  Ben Short Jun 28 '10 at 22:59

Its the File System Redirect, but you can bypass

Instead of

C:\windows\system32

(which the redirector will grab) use

C:\windows\sysnative\dnscmd.exe
share|improve this answer
    
oddly the Windows 7 & Windows Server 2008 machines I am testing this on do not recognise the SysNative alias. Any thoughts on why this may occur? :) –  Ben Short Jul 16 '10 at 0:04
    
Scratch that - found out it was because I was running 64 bit Powershell, and not 32, which meant the Wow64 layer was not kicking in. –  Ben Short Jul 16 '10 at 0:31

This is not very timely, but in Windows 8.1 I have found that it looks for it in System32 but doesn't find it. Strangely it exists on the system, but in the winsxs directory instead. Copying it to System32 allowed it to run as expected. I don't have any explanation as to why this is, but if you hit this issue it may be a workaround for you.

share|improve this answer
    
You could also add the folder it is in to the path variable. –  Falcon Momot Oct 9 '13 at 0:27

just install "DNS server tools" feature. Remote Server Administration Tools -> role based tools -> DNS server tools

share|improve this answer
    
This is a very old question and it has an accepted answer. Also, your solution doesn't fit the problem, as the DNS tools were installed, they just disappeared. See the accepted answer and the comments to the question. –  Sven Dec 10 at 15:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.