PowerShell $Profile: The six options and their precedence

There are a total of six different profiles than can be created in PowerShell by default. Four of them can exist that are applied to the PowerShell console:

1$PROFILE | Format-List -Force

profiles1a.jpg

And four of them can also exist that are applied to the PowerShell ISE (Integrated Scripting Environment):

1$profile | Format-List -Force

profiles2a.jpg

Two of the profiles are the same between the PowerShell console and ISE which gives you a total of six possible profile combinations that can be used to load items when you start PowerShell depending on if you want it to load for all users or for the current user and for all hosts or for the current host.

Keep in mind, if you're sharing scripts with others, be sure to test your code with no profile before sharing it. To accomplish this, start the PowerShell console with -noprofile:

1powershell.exe /?

profiles3a.jpg

The ISE can also be started with the -noprofile option:

1powershell_ise.exe /?

profiles4a.jpg

I created all of the possible profiles for the ISE and based on my testing, this is the order they're applied in:

profiles5a.jpg

I also created all of the possible profiles for the PowerShell console, added variable creation, and incremented the value of the variable in each profile to get a better idea of the precedence of each profile script:

profiles6a.jpg

One thing that the variables that I've defined in each of my profile scripts also tells us is that even though profiles are merely scripts that execute when PowerShell is launched, that any variable defined in them loads in the global scope by default. This can also be confirmed by taking a look at the global section of the about_Scopes help topic.

To learn more about PowerShell profiles see the about_Profiles help topic.

µ