Editing your Profile file

PowerShell Team

$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


Discussion is closed.

Feedback usabilla icon