To change the default directory that PowerShell starts in, you have several options depending on how you launch PowerShell and whether you want the change to be permanent or just for specific shortcuts. Here are the most common methods:
1. Change the Start Directory via PowerShell Profile
You can add a command to your PowerShell profile script to automatically change the directory every time a new PowerShell session starts.
Steps:
Open PowerShell.
Check if you have a profile file:
powershell
Test-Path $PROFILE
If it returns False, create one:
powershell
New-Item -Path $PROFILE -ItemType File -Force
Edit your profile:
powershell
notepad $PROFILE
Add this line to the end of the file:
powershell
Set-Location "C:\Your\Desired\Directory"
Replace C:\Your\Desired\Directory with your preferred path.
Save and close the file.
Now, every time you start PowerShell, it will automatically change to that directory.
2. Change the Start Directory for a Shortcut
If you launch PowerShell from a shortcut (e.g., on your desktop or taskbar), you can set the "Start in" directory:
Right-click the PowerShell shortcut and select Properties.
In the "Start in" field, enter your desired directory path (e.g., C:\Your\Desired\Directory).
Click OK.
Now, launching PowerShell from that shortcut will start in your specified directory.
3. For Windows Terminal (if using PowerShell there)
If you use Windows Terminal:
Open Windows Terminal.
Click the down arrow next to the tab bar and select Settings.
Under Profiles, select PowerShell.
Find the "Starting directory" field and set it to your desired path.
Save the settings.
Summary Table
Method
Scope
How To Change
PowerShell Profile
All PowerShell starts
Add Set-Location to $PROFILE
Shortcut Properties
That shortcut only
Set "Start in" in shortcut properties
Windows Terminal
Windows Terminal only
Set "Starting directory" in Terminal settings
Choose the method that best fits your workflow! If you need more details for a specific scenario, let me know.