Welcome to MSDN Blogs Sign in | Join | Help

Editing your Profile file

$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.

Cheers!

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

Published Thursday, December 28, 2006 4:33 PM by PowerShellTeam
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Editing your Profile file

After editing your profile file, you can load the new profile file (kind of restarting PowerShell session) with command:

. $profile

Cheers,

Aleksandar

http://powershellers.blogspot.com

Friday, December 29, 2006 5:32 AM by aleksandar

# re: Editing your Profile file

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?

Friday, January 12, 2007 8:00 PM by gorshing

# re: Editing your Profile file

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.

Friday, May 18, 2007 10:55 AM by Ryan cromwell

# re: Editing your Profile file

Ryan;

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

http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx

Lee

Friday, May 18, 2007 12:24 PM by PowerShellTeam

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker