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

  1. Right-click on the PowerShell icon
  2. Select “Properties”
  3. Change the working folder to a directory of your choice
  4. For the desktop, enter %USERPROFILE%\Desktop.

Method 2

  1. Start PowerShell
  2. Type notepad $profile
  3. 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
Last modified October 11, 2022: update (8216439)