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
Nice.
Categories: PowerShell