How to start PowerShell in a specified directory
Environment
Windows
What I want to do
I think it is troublesome to switch the directory every time when you start PowerShell.
So, to start it in the specified current directory every time, change it as follows.
Before
# At startup
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS J:\>
After
In this case, I will change the settings so that it starts as Desktop.
# At startup
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS C:\Users\username\Desktop>
Method 1
- Right-click on the PowerShell icon
- Select “Properties”
- Change the working folder to a directory of your choice
- For the desktop, enter
%USERPROFILE%\Desktop
.
Method 2
- Start PowerShell
- Type
notepad $profile
- Edit the profile.ps1
This setting will also come into effect when you run PowerShell from the command prompt.
For example, even if the current directory on the command prompt is not Desktop, PowerShell will use Desktop as the current directory.
Example contents of profile.ps1
You can change the username
by yourself.
Set-Location C:\Users\username\Desktop