-2

I am trying to print path using echo on PowerShell, but the output is %Path%.

PS C:\> echo %Path%
%Path%

Could you tell me how to go about this?

Ansgar Wiechers
  • 184,186
  • 23
  • 230
  • 299
  • possible duplicate of [Echo %path% on separate lines?](http://stackoverflow.com/questions/5114985/echo-path-on-separate-lines) – xXhRQ8sD2L7Z Dec 02 '14 at 21:32

2 Answers2

4

In PowerShell environment variables are expanded via the env scope:

PS C:\> $env:Path
%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows;...

%xxx% variables are a CMD thing.

Ansgar Wiechers
  • 184,186
  • 23
  • 230
  • 299
2

%Path% is a commandline variable, which is not supported in PowerShell. You'd need to use the appropriate environment variable:

echo $env:Path
KevinD
  • 2,932
  • 2
  • 21
  • 25