Powershell: Profile

A Powershell profile is a script file that is run each time a new Powershell is opened.

You can define session-specific items in it (variables, aliases, functions, etc.) or call other scripts and commands at the start of a new Powershell session.

General Notes

Names & Locations

Profile files are expected to be found under specific paths, with specific filenames (see below).

On this page, only the Microsoft Windows paths are listed; paths for Linux or MacOS can be found in the official Powershell profile documentation.
(Note: I have omitted variables and paths specific to the PowerShell ISE: I’ve never used it much myself and it’s also no longer under active development).

The order in which the profile scripts are executed can also be important:
A profile that is applied at a later stage (e.g. 4) overrides a value that was set at an earlier stage (e.g. 1).

Windows Powershell (≤ Version 5.1)

“Windows Powershell” is the name for the variant of Powershell that is only available for Microsoft Windows.

Order Profile Type Predefined variable Location and filename
1 All Users & All Hosts $PROFILE.AllUsersAllHosts $PSHome\profile.ps1
2 All Users & Current Host $PROFILE.AllUsersCurrentHost $PSHome\Microsoft.PowerShell_profile.ps1
3 Current User & All Hosts $PROFILE.CurrentUserAllHosts $Home\Documents\WindowsPowerShell\profile.ps1
4 Current User & Current Host $PROFILE.CurrentUserCurrentHost (= $PROFILE) $Home\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Powershell (≥ Version 6)

With version 6, PS became cross-plattform and open-source; it was renamed to “Powershell Core” for version 6.x and then to simply “Powershell” since version 7.x

Order Profile Type Predefined variable Location and filename
1 All Users & All Hosts $PROFILE.AllUsersAllHosts $PSHome\profile.ps1
2 All Users & Current Host $PROFILE.AllUsersCurrentHost $PSHome\Microsoft.PowerShell_profile.ps1
3 Current User & All Hosts $PROFILE.CurrentUserAllHosts $Home\Documents\PowerShell\profile.ps1
4 Current User & Current Host $PROFILE.CurrentUserCurrentHost (= $PROFILE) $Home\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

Starting a Powershell without a profile

Sometimes you need to start a fresh and clean Powershell, without any setup; for that, call the Powershell executable with the -NoProfile parameter:

powershell -NoProfile # "Windows Powershell" (up to v5.1)
pwsh -NoProfile       # "Powershell" (since v6)