Create (and Edit) your Profile Script

by Nov 16, 2010

Profile scripts are automatically executed whenever PowerShell launches. Your profile script is the perfect place to customize your PowerShell environment, change the prompt, colors, and make any changes you would like to keep in all of your sessions.

To create and/or edit your PowerShell profile script, here is a line that makes sure the profile script exists before it opens it in the ISE PowerShell editor:

If ((Test-Path $profile) -eq $false) {New-Item $profile -type file -force -ea 0 |
   Out-Null$profile

If you are sure the profile already exists, you can shorten the line:

ise $profile

You need to make sure the execution policy allows script execution if you want your profile script to run automatically the next time you launch PowerShell. For example:

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned -Force

Twitter This Tip!
ReTweet this Tip!