PowerShell: How to quickly switch to your home directory

You certainly know the commands cd and Set-Location. It stands for change directory. I hope you also know the commands cd \ and cd .. But what about cd ~ ?

Type cd ~ to switch to your home directory.

cd ~


Set-Location ~


Instead of ~ , the environmental variable USERPROFILE can be accessed.

cd $env:userprofile


Or use $home.

cd $home


Well. Next I tried to use it for copying. Ant it works.

Copy-Item -Path C:\temp\dummyfile1.txt -Destination ~\Documents



Categories: PowerShell

Tagged as: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.