我们正在尝试创建一个包含变量的数组,并将该数组扩展后传递给脚本,然后通过Start-Job运行该脚本。但实际上它失败了,我们无法找到原因。也许有人可以帮忙!
即使$config.name被正确设置,还有什么想法吗?
提前感谢您!
$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被正确设置,还有什么想法吗?
提前感谢您!