如何使用powershell使用不同的参数集执行数据工厂管道?

如何使用powershell使用不同的参数集执行数据工厂管道?,powershell,azure-data-factory,azure-devops-pipelines,Powershell,Azure Data Factory,Azure Devops Pipelines,我需要使用不同的参数集多次运行管道?您能帮助我们如何迭代执行多组参数吗 以下代码不起作用: $fileNames = '"prepTable" = "test_1_ddl"', '"prepTable" = "test_2_ddl"' $parameters = $fileNames | ForEach-Object { Invoke-AzDataFactoryV2Pipeline -ResourceGroupN

我需要使用不同的参数集多次运行管道?您能帮助我们如何迭代执行多组参数吗

以下代码不起作用:

$fileNames =  '"prepTable" = "test_1_ddl"', '"prepTable" = "test_2_ddl"'

$parameters = $fileNames | ForEach-Object {
Invoke-AzDataFactoryV2Pipeline -ResourceGroupName $(rg_nm) -DataFactoryName $(adf_nm) -PipelineName pl_common_Table_Creation_updated -Parameter $parameters }

您可以在PowerShell中创建哈希表数组,如下所示:

$prepTables =  @{'prepTable' = 'test_1_ddl'}, @{'prepTable' = 'test_2_ddl'}
然后可以在循环中使用它,如:

$prepTables =  @{'prepTable' = 'test_1_ddl'}, @{'prepTable' = 'test_2_ddl'}
$result = $prepTables | ForEach-Object {
    # the $_ Automatic variable represents a single item (hashtable) from the aray
    Invoke-AzDataFactoryV2Pipeline -ResourceGroupName $rg_nm -DataFactoryName $adf_nm -PipelineName 'pl_common_Table_Creation_updated' -Parameter $_
}
就我个人而言,我讨厌那些长代码行,所以请尝试使用

另外,我在这里假设您的
$(rg_nm)
$(adf_nm)
只是实际ResourceGroupName和DataFactoryName的占位符。
上面的代码使用这些变量。

不起作用吗?发生了什么事?你能给管道打一次电话吗?将问题分解为更小的部分,并实际解释问题所在。感谢您的回复@Nick.McDermaid获取以下错误:无法验证参数“parameter”上的参数。参数为null或为空。请提供一个不为null或空的参数,然后重试该命令。您正在使用
$parameters
作为变量,以收集orEach对象循环内命令的结果。因此,相同的$parameters变量在循环中为空(
-Parameter$parameters
)。
-Parameter
需要一个哈希表,请看我在powershell方面缺乏经验,如何将$parameters作为Hastable传递?我想为以下参数运行两次管道:““prepTable”=“test_1_ddl””,““prepTable”=“test_2_ddl””我们没有收到您的消息。。我的回答解决了你的问题吗?如果是,请点击✓ 左边的图标。这将帮助其他有类似问题的人更容易地找到它,并有助于激励其他人回答你将来可能遇到的任何问题。
$prepTables =  @{'prepTable' = 'test_1_ddl'}, @{'prepTable' = 'test_2_ddl'}
$result = $prepTables | ForEach-Object {
    $splatParams = @{
        ResourceGroupName = $rg_nm
        DataFactoryName   = $adf_nm
        PipelineName      = 'pl_common_Table_Creation_updated'
        Parameter         = $_   # the $_ Automatic variable represents a single item (hashtable) from the aray
    }
    
    Invoke-AzDataFactoryV2Pipeline @splatParams
}