我们正在尝试创建一个包含变量的数组,然后将该数组作为扩展传递给一个脚本,该脚本应由 Start-Job 运行。但实际上它失败了,我们无法找到原因。也许有人可以帮忙!?
$arguments= @()
$arguments+= ("-Name", '$config.Name')
$arguments+= ("-Account", '$config.Account')
$arguments+= ("-Location", '$config.Location')
#do some nasty things with $config
Start-Job -ScriptBlock ([scriptblock]::create("& .'$ScriptPath' [string]$arguments")) -Name "Test"
它失败了
Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
+ CategoryInfo : InvalidData: (:) [Select-AzureSubscription], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.Profile.SelectAzureSubscriptionCommand
+ PSComputerName : localhost
即使 $config.name 设置正确。
有任何想法吗?
先感谢您!