Where to Store Your PowerShell Profiles

I recently decided to get on the PowerShell bandwagon again (after starting many times and then forgetting “everything”), so I went to Scott Hanselman’s blog about using the Visual Studio environment from the PowerShell prompt. I followed everything in his article except where I was supposed to store my profile (i.e. startup script) for PowerShell.  It turns out that there are four places where you can put your profile, depending on whether it’s per-user or machine-wide.  They are as follows:

  • %windir%\system32\WindowsPowerShell\v1.0\profile.ps1

This profile applies to all users and all shells.

  • %windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1

This profile applies to all users, but only to the Microsoft.PowerShell shell.

  • %UserProfile%\My Documents\WindowsPowerShell\profile.ps1

This profile applies only to the current user, but affects all shells.

  • %UserProfile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

This profile applies only to the current user and the Microsoft.PowerShell shell.

I found this information on the following MSDN page.  I’m still learning about what the “Microsoft.PowerShell shell” is, but that’s where Scott recommended putting it.

So, here are the lines I added to the end of Scott’s VsVars32 function:

[sourcecode language=”powershell”]

# add a call to set-consoleicon as seen below…hm…!
. ‘C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Set-ConsoleIcon.ps1’
Set-ConsoleIcon ‘C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vspowershell.ico’
[/sourcecode]

Also, for those of your writing PowerShell scripts, note that the ‘#’ character is used at the beginning of a line to indicate a comment.

Finally, if you modify your profile and want to reload it, you can just issue the following command from the PowerShell prompt: