Use import-module with a PowerShell PSSnapin Dll -


we have legacy powershell pssnapin (c#). want avoid having use installutil. following imports module pssnapin cmdlets exported:

import-module .\mysnapin.dll 

however, when run module cmdlets, fail due not being able find referenced assemblies (specifically, enterprise library dlls).

is there neat way working?

(the pssnapin dll , referenced assemblies in same build directory, , when use installutil, dependencies resolved correctly)

snap-ins bit different modules. first need register snap-in, using installutil.exe:

ps> $installutil = join-path $([system.runtime.interopservices.runtimeenvironment]::getruntimedirectory()) "installutil.exe" ps> & $installutil "c:\path\to\mysnapin.dll" 

after registering snapin assembly, can load powershell session add-pssnapin:

ps> add-pssnapin mysnapin 

Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -