PowerShell seems to be unable to see or run certain executables RRS feed

  • Question

  • Hi guys! This isn't a scripting question per se—I'm just confused as to what might be going on and I'm looking for guidance.

    When I'm running in PowerShell, and I want to run certain commands, PS acts like it doesn't know what they are, even though I can run those commands just fine from a CMD prompt. What's weirder is that even though the files don't have the +H attribution, when I do a DIR in PS, it doesn't even see them!

    The two examples I can think of off the top of my head are DSQUERY and NBTSTAT. I'm well aware that there are built-in tools for a lot of the functions given by these two programs, but I'm still somewhat new to PowerShell and oftentimes I can rattle off exactly what I'm looking for with DSQUERY rather than have to look up the equivalent builtin command.

    Here's what happens if I try to run DSQUERY:

    PS C:\windows\system32> DSQUERY user -name Andrew
    DSQUERY : The term 'DSQUERY' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + DSQUERY user -name Andrew
    + ~~~~~~~
        + CategoryInfo          : ObjectNotFound: (DSQUERY:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    If I try to search for the file:

    PS C:\windows\system32> dir DSQUERY.exe
    dir : Cannot find path 'C:\windows\system32\DSQUERY.exe' because it does not exist.
    At line:1 char:1
    + dir DSQUERY.exe
    + ~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\windows\system32\DSQUERY.exe:String) [Get-ChildItem], ItemNotFoundEx
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemComman

    If I try to search for the file, I get the following (with a working query included as well):

    PS C:\windows\system32> where.exe DSQUERY
    INFO: Could not find files for the given pattern(s).
    PS C:\windows\system32> where.exe explorer

    From a command prompt, though, I get the following:

    C:\Users\Andrew\Desktop>where dsquery

    I get identical results if I try to run NBTSTAT or DSGET.

    I am at a TOTAL loss here. Anybody have any idea why this is happening?

    Monday, July 20, 2015 8:11 PM


  • Are you are running the 32 bit version of PowerShell?


    Monday, July 20, 2015 8:20 PM

All replies

  • Are you are running the 32 bit version of PowerShell?


    Monday, July 20, 2015 8:20 PM
  • I am, as it turns out. Is it unable to see those commands because they're 64-bit executables?
    Tuesday, July 21, 2015 2:38 PM
  • Never mind, it looks like I've answered my own question: running the 64-bit version of PS allows me to use them.

    Man, such a simple answer... I knew I was overlooking something.

    Tuesday, July 21, 2015 2:42 PM
  • Chances are you will never forget it now.


    Tuesday, July 21, 2015 2:58 PM