Editing your Profile file

Rate This
  • Comments 4

$hay has a new scripting blog at http://scriptolog.blogspot.com/ .  His first blog entry Restart your engine - The PowerShell Way, talks about how he frequently edits his PowerShell profile file and then restarts his session.  In his directions he says:

2: type: Notepad $profile to open your profile file

I looked at this and thought about my Philosophy of Automation post and thought, if you are editing your profile a lot, you ought to automate that.  I quickly typed Notepad $Profile and added the following to the end of my profile file

function Edit-ProfileFile{
   Notepad $profile
Set-Alias epf Edit-ProfileFile

 At that point I asked myself, "hmm is 'E' the right alias shorthand for 'EDIT'".  So I did the following to find out:

PS> gal e*
CommandType     Name                          Definition
-----------     ----                          ----------
Alias           epal                          Export-Alias
Alias           e                             Edit-File
Alias           egp                           Edit-GlobalProfile
Alias           eghp                          Edit-GlobalHostProfile
Alias           ep                            Edit-Profile
Alias           ehp                           Edit-HostProfile
Alias           efun                          Edit-Function

So first, "E" is the right shorthand for "EDIT" but then I already had an "Edit-Profile" which was aliased to EP (not EPF).  Upon investigation, these were already provided to me when installed the PowerShell Community Extensions (PSCX). 

So the bottom lines are:

1) $hay is right, you should edit your profile file often to save the automation that you figure out.
2) Use the Philosophy of Automation model so that you just type "ep" instead of  "notepad $profile".
3) Download and learn the PowerShell Community Extensions so that you can stand on the shoulders of giants.


Jeffrey Snover [MSFT]
Windows PowerShell/MMC Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 3 and 8 and type the answer here:
  • Post
  • After editing your profile file, you can load the new profile file (kind of restarting PowerShell session) with command:

    . $profile




  • I am curious of what you have your execution-policy set as.

    I have mine set as AllSigned, and I have set up a script which will sign my profile after I edit it.

    Since I have set my ExecutionPolicy I must even sign my profile correct?

  • I have question regarding the $profile path.  Is it possible to make a wholesale change to the location of the profile?  At my office, our Domain profiles are stored on network shares which tends to cause a fair delay in the opening of a PS session as it loads my profile and the PSCX cmdlets, etc.  I'd like to change my PS profile to be a local path so it's quicker.

  • Ryan;

    You can use the machine-wide profiles if you don't want to use your roaming profile.



Page 1 of 1 (4 items)

Editing your Profile file