We have a legacy PowerShell PsSnapin (c#). I want to avoid having to use InstallUtil. The following imports a module with the PSSnapin cmdlets exported:
import-module .\MySnapin.dll
However, when I run the module cmdlets, they fail due to not being able to find referenced assemblies (specifically, Enterprise Library dlls).
Is there a neat way to get this working?
(The PsSnapin dll and all referenced assemblies are in the same build directory, and when I use installutil, the dependencies are all resolved correctly)
Snap-ins are a bit different from Modules. You first need to register the snap-in, using InstallUtil.exe:
After registering the snapin assembly, you can load it into your powershell session with
Add-PSSnapin: