simonhaines
simonhaines

Reputation: 501

Powershell and path environment variable

I would like powershell to use the environment variable "PATH" to resolve executables. I'm sure it should be able to do this, but here is what I get.

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

PS C:\> ${ENV:PATH} = "C:\WINDOWS\System32\"
PS C:\> ls ${ENV:PATH}\cmd.exe


Directory: C:\WINDOWS\System32


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        22/08/2013   8:03 PM     355840 cmd.exe

PS C:\> & cmd.exe
& : The term 'cmd.exe' 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:3
+ & cmd.exe
+   ~~~~~~~
+ CategoryInfo          : ObjectNotFound: (cmd.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Upvotes: 2

Views: 4712

Answers (1)

briantist
briantist

Reputation: 47772

Run Get-Command -Type Application to see what PowerShell is seeing as valid executables.

You may find a clue as to what's going on, such as all of the listed applications have (or don't have) a certain extension, which could indicate a problem with the PATHEXT environment variable.

Upvotes: 5

Related Questions