Using Profile Scripts

by Jun 13, 2014

You probably know that PowerShell supports profile scripts. Simply make sure the file found in $profile exists. It's a plain script that gets executed each time the PowerShell host launches.

So it's easy to configure your PowerShell environment, load modules, add snap-ins, and do other adjustments. This would shorten your PowerShell prompt and instead display the current location in the title bar:

function prompt
  'PS> '
  $host.UI.RawUI.WindowTitle = Get-Location

Note also that the profile script found in $profile is host specific. It works only for a given host (either the PowerShell console, or the ISE editor, or whatever else PowerShell host you are using).

To execute code automatically on launch of any host, use this file instead:


It is basically the same path, except the file name is now not using a host name anymore. Instead, the file name is called "profile.ps1" only.

Twitter This Tip! ReTweet this Tip!