スプラッティング演算子を使用する必要があります。powershellチームのブログまたはここstackoverflow.comをご覧ください。
次に例を示します。
@'
param(
[string]$Name,
[string]$Street,
[string]$FavouriteColor
)
write-host name $name
write-host Street $Street
write-host FavouriteColor $FavouriteColor
'@ | Set-Content splatting.ps1
# you may pass an array (parameters are bound by position)
$x = 'my name','Corner'
.\splatting.ps1 @x
# or hashtable, basically the same as .\splatting -favouritecolor blue -name 'my name'
$x = @{FavouriteColor='blue'
Name='my name'
}
.\splatting.ps1 @x
あなたの場合、あなたはそれをこのように呼ぶ必要があります:
$para = @{Name='name'; GUI=$true; desc='this is the description'; dryrun=$true}
. .\script1.ps1 @para