Azure devops 使用 devops 中的 powershell 脚本路径任务在 ADLS gen2 容器中分配角色 rwx

Azure devops assigment of roles rwx in ADLS gen2 container using powershell script path task in devops

我在将角色分配给存储容器 rwx 以便我的数据工厂可以 从 adls gen 2 读取数据。下面的脚本 运行 在 azure devops 中使用内联脚本很好 电源外壳 script.But 当我将它从文件路径更改为脚本时(位置是 github)。我已经把脚本放在下面 已经在 .ps1 扩展中。

[CmdletBinding()]
param(
 [parameter(Mandatory = $false)] [String] $resourcegroup_name,
 [parameter(Mandatory = $false)] [String] $factoryName,
 [parameter(Mandatory = $false)] [String] $storageaccount_name
 )

$principalID = (Get-AzDataFactoryV2 -ResourceGroupName $resourcegroup_name -Name 
$factoryName).identity.PrincipalId
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourcegroup_name -AccountName 
$storageaccount_name
$ctx = $storageAccount.Context
$filesystemName = "adftransformation"
$dirname = "mfg/"
$dir = New-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname -Directory - 
Permission r-x -Umask ---rwx---  -Property @{"ContentEncoding" = "UDF8"; "CacheControl" = "READ"}
$acl = (Get-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname).ACL
$acl = set-AzDataLakeGen2ItemAclObject -AccessControlType user -EntityID $principalID -Permission r-x 
-InputObject $acl 
Update-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname -Acl $acl

进入 devops 管道时出错

2020-06-03T14:29:18.8399468Z ##[error]Cannot validate argument on parameter 'Permission'. The argument "r-x" does not match the "([r-][w-][x-]){3}" pattern. Supply an argument that matches "([r-] [w-][x-]){3}" and try the command again.

我不确定为什么在选择脚本作为文件路径时会发生这种情况,相同的脚本 运行 在 内联脚本路径

This is the correct script  from Githubif you are taking as a file path.

[CmdletBinding()]
param(
 [parameter(Mandatory = $false)] [String] $resourcegroup_name,
 [parameter(Mandatory = $false)] [String] $factoryName,
 [parameter(Mandatory = $false)] [String] $storageaccount_name
 )
$principalID = (Get-AzDataFactoryV2 -ResourceGroupName $resourcegroup_name -Name 
$factoryName).identity.PrincipalId
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourcegroup_name - 
AccountName $storageaccount_name
$ctx = $storageAccount.Context
$filesystemName = "fsname"
$dirname = "mfg/"
$dir = New-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname 
-Directory -Permission rwxrwxrwx -Umask ---rwx---  -Property @{"ContentEncoding" = 
"UDF8"; "CacheControl" = "READ"}
$acl = (Get-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path 
$dirname).ACL
$acl = set-AzDataLakeGen2ItemAclObject -AccessControlType user -EntityID $principalID 
-Permission rwx -InputObject $acl 
Update-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $dirname - 
Acl $acl