cmdlets - Add Powershell Snapin for Powershell Module and Import Multiple Times -


i use sqlservercmdletsnapin custom powershell commandlet building. if add following code beginning of psm1:

if ( (get-pssnapin -name sqlserverprovidersnapin100 -erroraction silentlycontinue) -eq $null ) {     add-pssnapin sqlserverprovidersnapin100 }  if ( (get-pssnapin -name sqlservercmdletsnapin100 -erroraction silentlycontinue) -eq $null ) {     add-pssnapin sqlservercmdletsnapin100 } export-modulemember invoke-sqlcmd 

everything works great first time run:

import-module mymodule -force

however, second time run:

import-module mymodule -force

i following error:

add-pssnapin : item same key has been added.

and code can no longer call invoke-sqlcmd. best way add powershell snapin custom module?

you might want try specify module required own module through module manifest (.psd1). see requiredmodules here.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -