I've developed some powershell cmdlets and providers, and also devel开发者_如何学JAVAoped 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.
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.
精彩评论