Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I created a custom powershell cmdlet that i have registered in powershell. Of course everytime i close my specific powershell instance i have to execute the following to have access to the command again:

add-pssnapin MyCustomSnapIn

I've tried to google for the answer and the only thing i'm finding is to do the following:

export-console MyCustomCmdletPowerShell

But nothing i found tell you to reimport this into powershell or how to automatically reimport it into powershell (which i prefer). Apparently it doesn't happen automatically.

share|improve this question
1  
Have you tried adding the add-pssnapin command to your profile? –  Christopher Nov 10 '10 at 15:08
    
Sorry Christopher but can you explain more? Does PowerShell have some type of profile? I'm pretty new (few days) to powershell. –  coding4fun Nov 10 '10 at 15:11

1 Answer 1

up vote 2 down vote accepted

You need to add the add-pssnapin MyCustomSnapin command to your profile. Once you do that, the snapin will load each time the Powershell environment runs.

On XP, you can reach your personal Powershell profile in My Documents\Windows Powershell\profile.ps1.

There are actually 4 different profiles in Powershell. Check out this MSDN article for more information - http://msdn.microsoft.com/en-us/library/bb613488(VS.85).aspx.

share|improve this answer
    
In PS you can notepad $profile to edit your profile too. –  Chris S Nov 10 '10 at 15:34
    
Thanks Chris. That was it. I was confused at first and tried to use the file the export command created above which didn't work of course since its an XML file. I just put the add command to my profile and everything worked correctly. I appreciate your help –  coding4fun Nov 10 '10 at 15:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.