0

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.

2
  • 1
    Have you tried adding the add-pssnapin command to your profile? Nov 10, 2010 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, 2010 at 15:11

1 Answer 1

2

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.

2
  • In PS you can notepad $profile to edit your profile too.
    – Chris S
    Nov 10, 2010 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, 2010 at 15:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .