PowerShell Profile
An overview of the four PowerShell profiles, how they load, what order they run in, and what to put in them as an automation engineer.
This week I was at the PowerShell Usergroup in Munich. They wanted information about PowerShell Profiles, so I gave a talk on the topic. Here is the content.
The Four Profiles
There are 4 PowerShell Profiles loaded on startup of the console – but there can be more in your environment, because you have two PowerShell profiles per console. VSCode, PowerShell ISE, and the PowerShell command prompt each have two profiles: one for All Users, one for the current user.
Additionally you have a profile for Windows PowerShell and a separate one for PowerShell Core – so there can be quite a few profiles on your computer.
Use the following commands in your preferred console to get the actual profile paths:
$profile.AllUsersAllHosts
$profile.AllUsersCurrentHost
$profile.CurrentUserAllHosts
$profile.CurrentUserCurrentHost
They are loaded in exactly this order.
What I Have in My Profile
As an automator my focus is on execution duration, so the most relevant part is showing execution time in the prompt. I also colour-code the path by provider (e.g. FileSystem vs. Registry).
You can find my profile on GitHub.
Example Profile Paths
# PowerShell Core with VSCode
C:\Users\patrick\Documents\PowerShell\Microsoft.VSCode_profile.ps1
# Windows PowerShell with VSCode
C:\Users\patrick\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1
# Windows PowerShell with ISE
C:\Users\patrick\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
# Windows PowerShell in the Console
C:\Users\patrick\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1