Th开发者_运维百科e main calling script defines 3 parameters, and I'd like all the module can use them, one way is to use global script, but looks bad.
I hope we can use something like the following to pass the parameters, but doesn't work
import-module "$currentPath\ETLLib.psm1" $a $b $c
my main script is like:
$a
$b
$c
import-module "$currentPath\ETLLib.psm1" $a $b $c
import-module "$currentPath\Tranform.psm1" $a $b $c
ETLLib.psm1
param($a $b $c)
Tranform.psm1
param($a $b $c)
The ArgumentList
parameter of Import-Module
should be used.
Test.psm1:
param($a, $b, $c)
Write-Host $a
Write-Host $b
Write-Host $c
Import using ArgumentList
:
Import-Module Test -ArgumentList arg1, arg2, arg3
Output:
arg1
arg2
arg3
精彩评论