PowerShell Tips for System Administrators: Profiles

A profile in PowerShell is nothing more than a script file that is run when the shell starts. This file is very handy to create variables, functions, or change settings that you find you use a lot. Instead of having to re-import a library of functions or change the shell’s settings each time you start up PowerShell.

The variable $profile holds the name of the file that you are using for the current shell. PowerShell doesn’t create this file, so it won’t exist out of the box, but the variable will still hold the name. For example, on my box it is:

You can put anything in this file that you can put into a script file, so feel free to create functions, set variables and run commands. Any changes made to the file won’t be used by the current shell, so you’ll need to restart to see any effect. And remember that if you are going to load any other script files in the profile you need to precede the script with a single dot (.) for the functions and variables in that script file to remain visible in your new shell: