Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At the cmd command prompt, this command will take me to my home directory:

cd %UserProfile%

At the PowerShell command prompt, the same command produces this error:

Set-Location : Cannot find path 'C:\%UserProfile%' because it does not exist.
At line:1 char:3
+ cd <<<<  %UserProfile%
    + CategoryInfo          : ObjectNotFound: (C:\%UserProfile%:String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

What is the equivalent command in PowerShell?

share|improve this question
up vote 13 down vote accepted

You can get to your home dir with:

cd $home

share|improve this answer
3  
As an add-on to this answer, %UserProfile% does not literally translate to $home, and, instead, you should use the $env:UserProfile variable. – SpellingD Jul 19 '12 at 15:57

This shorthand is one of my favorites:

cd ~

You can also do:

cd ~\Deskt 

(Hit the Tab key to auto-complete, it works nicely when you are buried in some deep directory and need to copy something to Desktop or somewhere in your $HOME)

share|improve this answer
    
Nice, somehow I didn't know you could use ~ in PowerShell! – Nate Barbettini Dec 1 '15 at 0:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .