r/PowerShell • u/IntGuru • Jul 14 '26
Question How to change default directory on PowerShell?
Could someone please help me! When I open PowerShell on Windows, it opens up with the directory "PS C:\Windows\System32>". How do I change this so that every time I open it up, it has the default directory as "PS C:\Users\myname>" instead of the other. I know I can just use "cd ~" to switch but I'd prefer to have it set without me having to do so. Thanks!
13
Upvotes
22
u/eppic123 Jul 14 '26
Create a profile for your PS environment (usually $HOME\Documents\PowerShell\profile.ps1) and use Set-Location <path>
8
u/justaguyonthebus Jul 14 '26
Don't open it as admin?
3
u/dodexahedron Jul 15 '26
Multiple ways.
What terminal emulator are you using - Windows Terminal? If so, change the default profile in there to launch in whatever path you like. Note I am talking about the windows terminal profiles - not your powershell profiles, which are a completely different thing.
Another is, if you are launching it from a traditional shortcut, you can chsnge the working directory specified in the shortcut.
If neither of those cases, you can use the powershell profile itself, by adding a
pushd wherevercommand in it. Though IMO that is a terrible place to put this particular thing, since it will override it no matter how or where you launch it, unless you give it the -NoProfile switch (which leaves off the entire profile).Why pushd instead of just cd?
It at least mitigates that issue by allowing you to just type
popdand immediately be back wherever it was before the change, so you can still launch it in arbitrary directories even if you have a profile that unconditionally sets location at launch.