1

I've developed some powershell cmdlets and providers, and also developed an application to host powershell environment. I would like to run those cmdlets and providers in this hosted powershell environment. I'm wondering whether this is possible and how to register my custom snapin. Thanks for the help.

1 Answer 1

2

The default installer for a PSSnapin extended class creates a series of registry keys for the snapin. These are created under HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\. The string values are: PowerShellVersion, Vendor, Description, Version, ApplicationBase, AssemblyName, ModuleName, VendorIndirect and DescriptionIndirect.

Look at an existing registered PSSnapin and use that as for your template to create the key and the string values. After creating the key and all the string values (especially the ApplicationBase, AssemblyName and ModuleName values) then add the snapin to a PSRunspaceConfiguration object with the AddPSSnapin() method before you instantiate a new runspace object.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the reply. As far as I understand from Microsoft documentation, AddPSSnapin can only add a snapin at runtime when it is already registered, which means it has to have some registry entry populated before you can call AddPSSnapIn. Do you have to run installutil.exe for your snapin?
awatto, I see what you mean now. Sorry for the misinterpreting your question. So, I've updated the answer with something more suitable. :)
If populating those registry keys are the only thing need to do, this is definitely the answer. Thanks.
I don't have a setup to re-test at the moment but I've used that in the past. You can remove the "answer tick" until your satisfied. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.