Skip navigation
Configure commands to run when opening PowerShell instances

Configure commands to run when opening PowerShell instances

Q. How can I configure commands to run when opening a PowerShell instance?

A. There are a number of ways to run commands when launching a PowerShell instance such as changing the command shortcut however the better option is to utilize a PowerShell profile that contains commands that will be executed when a new PowerShell instance is launched. There are actually 6 different PowerShell profiles available however typically you will use only one. The six profiles are listed below in addition to when they are used.


Profile Path
Current user and host $HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Current user, all hosts $HOME\Documents\WindowsPowerShell\profile.ps1
All users, current host $PSHOME\Microsoft.PowerShell_profile.ps1
All users, all hosts $PSHOME\profile.ps1
Current user and host in ISE $HOME\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
All users, current host ISE $PSHOME\Microsoft.PowerShellISE_profile.ps1


Typically you will use the profile for the current user and host which is stored in file $HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 that is referenced through $profile. An easy way to create this profile is:

#Check if exists
Test-Path $profile
#Create if does not exist
New-Item -Path $profile -ItemType file -Force 
#Then edit in notepad
Notepad $profile


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.