Creating Powershell Profile


Written by:

I talked with my friend today, talked about work, he told me that he has some scripts that he uses a lot in his day to day job, and thought about creating a script that loads all of them at once. The first thing I told him is “Why don’t you set up a profile?” he waited for a few seconds and told me that he doesn’t know about profiles. If you are reading this and feel the same, this post is for you 🙂 Powershell profile is a script that runs every time we start the shell. They can have customization elements like windows size and colors, load modules functions, and scripts, or create an alias or any PS-providers. Creating a profile is much easier as you think. Powershell has a global variable name $Profile that hold the profile file path. By default, the file does not exist even if the variable holds it. You can type $profile to see the location: Almost every Powershell editors have their own profiles VS Code: C:\Users\MyUser\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1 Powershell ISE: C:\Users\MyUser\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

Creating Powershell Profile:

I say “profiles” as we have four profiles for each shell, but we won’t dive there. To create our profile, first we need to check if we have one already:

we can see we don’t have one, so we create one with new-item cmdlet:

Now you can verify the creation of the file with the same test-path we used earlier. if everything went ok, now you see “True”

After we created our profile file, all left for us is to edit it, with any app we want, you can quickly open the file with your favorite editor:

Here some ideas to add to your profile:

1.Change the prompt, and add [Admin] if its elevated session:

2. Change the color of the window and font:

3. Add your name to the windows title:

4. Load modules and add custom functions:

Now just save and open a new shell
End Reult
There is no limit to what you can add to your profile. You can always add or remove new things from your profile. Use it as your toolbox, add some style and make it your own. If you want to read more about Powershell profile, Microsoft did a great job with its Documentation. You can use get-help about_profiles or read the online version here.

Comments are closed.