Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell Azure DevOps-从PS脚本中调用PS脚本_Powershell_Azure Devops_Azure Powershell - Fatal编程技术网

Powershell Azure DevOps-从PS脚本中调用PS脚本

Powershell Azure DevOps-从PS脚本中调用PS脚本,powershell,azure-devops,azure-powershell,Powershell,Azure Devops,Azure Powershell,您不能从Azure PowerShell任务中的脚本中调用脚本吗 背景- 我有一个Azure Repo,其中有两个脚本,我们称它们为script0和script1。没有正在进行的构建,因此没有构建管道。只有一个发布管道。它从Azure存储库Git中获取的工件。我在发布管道中只有一个任务,那就是Azure PowerShell任务 在主脚本script0中,我有一个for循环,它要求我运行script1,而不运行循环中发生的其他事情 就我的一生而言,我不知道如何才能做到这一点。最糟糕的是,它在本地

您不能从Azure PowerShell任务中的脚本中调用脚本吗

背景-

我有一个Azure Repo,其中有两个脚本,我们称它们为script0和script1。没有正在进行的构建,因此没有构建管道。只有一个发布管道。它从Azure存储库Git中获取的工件。我在发布管道中只有一个任务,那就是Azure PowerShell任务

在主脚本script0中,我有一个for循环,它要求我运行script1,而不运行循环中发生的其他事情

就我的一生而言,我不知道如何才能做到这一点。最糟糕的是,它在本地工作。此外,其他一切都在循环中工作。我已经尝试了很多方法来修复它,但现在我将从以下内容开始:运行时抛出的错误

$TeamFoundationCollectionUri$TeamProject/testscript.ps1$stage$FunctionHosts[$i]$hashtable | select-First 6.键[$i]$ResourceGroupName$location$functionApps$AdminClientSecret$VaultName$JsonFile 现在,请注意——这是script0的一部分——主脚本

以下是错误:

模糊区域为script0,testscript.ps1为script1

我几乎什么都试过了

使用呼叫接线员& 使用\、/、/ 调用表达式-命令 调用命令 还尝试了powershell.exe命令
正如您所知道的,所有这些都不起作用。

我是通过在脚本所在的路径之前使用Call操作符来实现这一点的。所以,我这样做了:

&$System.ArtifactsDirectory\$System.TeamProject\testscript.ps1


它成功了。

太棒了!谢谢你在这里分享你的解决方案,你可以接受它作为答案,这样它可以帮助其他社区成员谁得到同样的问题,我们可以存档此线程,谢谢。做到了!谢谢