Home » Questions » Computers [ Ask a new question ]

Setting $HOME in PowerShell

Setting $HOME in PowerShell

How do I change my default home directory to "C:\Users\khornsby" for every time I open powershell?

Asked by: Guest | Views: 168
Total answers/comments: 2
Guest [Entry]

"The variable is read only by default, but can be removed with the -Force switch to Remove-Variable. To make your change persistent across sessions, you can make a profile file which is much like a .bashrc (For bash on Linux) except for Powershell.

In your Documents directory (normally C:\Users\YOUR_USERNAME_HERE\documents) for your user account, create a WindowsPowerShell folder (named exactly like that) if one does not already exist. Inside the folder, create a text file called profile.ps1 (ensure it's not profile.ps1.txt).

Inside the file, place anything you want executed when you open Powershell.

example:

Write-Host ""Hi John, welcome back!""
Remove-Variable -Force HOME
Set-Variable HOME ""C:\Users\khornsby""

result:"
Guest [Entry]

"Even easier ... open up advanced system settings ...

C:\> systempropertiesadvanced

Add a new system variable named HOME with the path to your profile

Restart explorer or log out and back in ...

PS C:\> $Env:home
---"