- Docs
- /
24 Jul 2022 22678 views 0 minutes to read Contributors
A PowerShell profile is a script that runs when I load an instance of PowerShell. I favor having nice little messages each time I load PowerShell, especially when they’re in the flavor of Futurama.
Let’s get a profile made and get the magic started. I can find out where my default profile is stored by typing $profile inside PowerShell. It is one of the built-in automatic variables (See help for more info on automatic variables).
By default, this file doesn’t exist. So, I’m going to need to create the file before I can add any code to it.
New-Item $profile -ItemType File -Force
Now that my profile is created, I can easily edit it with my preferred text editor. For simplicity, I’m going to use notepad. Running the following will open up that file via notepad.
Notepad $profile
Let’s put some code into it and see what happens. We can put any text in it, so I’ll add a nice quote to my $profile.
Closing and reopening PowerShell should kick off that extra code.
NOTE: Profiles are simply PowerShell scripts (.ps1 files) that run when PowerShell starts up, so the execution policy will be applied. If I have a restrictive execution policy, I will end up with an error when I start up my PowerShell console.
I’m going to take a deeper look at the $profile variable and see what else I can find. To do that, I’ll use Get-Member and investigate.
$profile | Get-Member
This is showing me that there are four profiles that can be used by PowerShell.
Breaking down the profile names a bit, the Current User and All Users portion seems straightforward enough for the profile type, but what does Current Host and All Hosts refer to?
Without diving too much into the weeds, each host application that runs PowerShell can have two sets of profiles that are specific to that host application, broken down by Current User and All Users.
That means that I should see two profiles for each program that implements a PowerShell runspace: PowerShell console, PowerShell ISE, Visual Studio Code, etc.
In addition to the two sets of profiles per host application, I have two profiles defined for all hosts.
This makes for 6 total profiles with just regular PowerShell and PowerShell ISE. In my case, I also have Visual Studio Code installed, so I have 8 total profiles to work with!
In this article
Please choose a monitoring environment to connect to:
Enter your email address to recover your password.
Download link successfully sent. Check your email for details.
Reset password link successfully sent to . Check your email for details.
An email with a link for creating your password is sent to
Share link successfully sent to .
Your reply is send.
Download link successfully sent to . Check your email for details.
Download link successfully sent to . Check your email for details.
Download link successfully sent to . Check your email for details.
Download link successfully sent to . Check your email for details.
We received your request. We will contact you shortly