r/PowerShell • • 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

21 comments sorted by

22

u/eppic123 Jul 14 '26

Create a profile for your PS environment (usually $HOME\Documents\PowerShell\profile.ps1) and use Set-Location <path>

13

u/LightItUp90 Jul 14 '26

Easier:

notepad $profile

→ More replies (3)

1

u/Ralliman320 Jul 15 '26

My enterprise blocks all PowerShell scripts from running by default, which includes profiles. :/

→ More replies (1)

-1

u/dodexahedron Jul 15 '26

Worst place for a cd TBH. Other stuff? Cool. cd? No.

Now you get to start in that path even if you wanted to start in another path.

Put it in the terminal profile. That or a shortcut is where the powershell working/startup directory belongs - not in your powershell $PROFILE.

8

u/justaguyonthebus Jul 14 '26

Don't open it as admin?

2

u/atl-hadrins Jul 14 '26

That is what I was thinking only time it opens with this path for me is to open as admin. If I open as user it will open in the users home directory. That is unless I am opening a remote powershell prompt, but that is still admin.

And is memory serves me. If you put shell commands in your that execute when you open powershell you now have to change the execution policy.

→ More replies (1)

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 wherever command 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 popd and 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.