Resourcing the profile

Topics: Developer Forum
Jan 12, 2007 at 11:11 PM
First, thanks a lot for PSCX! This is a great companion for PowerShell.

I've got a suggestion you might want to consider: add an "Update-Profile" function that resources the profile, for when you modify it and don't want to relaunch the whole shell. It would basically do this:

function Update-Profile
. "$UserProfile"

And a simple alias:
Set-Alias rehash Update-Profile

This needs some modifications though, because with this, you'll get an error when the PSCX Snapin is added. You have to check whether it's alread there. Replace the "Add-PSSnapin Pscx" line in the default profile by:

$PscxSnapIns = &{ Get-PSSnapin Pscx | Measure-Object }
if ( $PscxSnapIns.Count -eq 0 ) { Add-PSSnapin Pscx; }

That's it!
Jan 12, 2007 at 11:53 PM
i've got similar functions in my profile, i'll check them in.
Jan 17, 2007 at 4:46 AM
This discussion has been copied to Work Item 7386. You may wish to continue further discussion there.