Equivalent of “cd %programfiles%” in PowerShell?

The principle is:

$Env:variablename

So you might try:

cd $Env:Programfiles

or to temporarily switch working directory to %Programfiles%\MyApp:

Push-Location -Path "$Env:Programfiles\MyApp"
#
# command execution here
#
Pop-Location

To list all environment variables you could do:

Get-ChildItem Env:

or use the convenient alias:

ls env:

Leave a Comment