Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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访问?_Powershell_Azure_Azure Powershell_Azure Automation - Fatal编程技术网

&引用;“读卡器和数据访问”;角色无法通过powershell访问?

&引用;“读卡器和数据访问”;角色无法通过powershell访问?,powershell,azure,azure-powershell,azure-automation,Powershell,Azure,Azure Powershell,Azure Automation,我试图在Azure中将“读卡器和数据访问”角色分配给我的服务主体,但它抛出了一个错误 我没有看到此角色在上列出,但在azure门户上可见 New-AzureRmRoleAssignment -RoleDefinitionName 'Reader and Data Access' ` -ServicePrincipalName $app.ApplicationId` 新AzureRmRoleAssignment:过滤器“roleName eq”读卡器和数据 不支持访问“

我试图在Azure中将“读卡器和数据访问”角色分配给我的服务主体,但它抛出了一个错误

我没有看到此角色在上列出,但在azure门户上可见

New-AzureRmRoleAssignment 
      -RoleDefinitionName 'Reader and Data Access' `
      -ServicePrincipalName $app.ApplicationId`
新AzureRmRoleAssignment:过滤器“roleName eq”读卡器和数据 不支持访问“”。支持的筛选器为roleName eq或 “{value}”或类型eq“内置角色|自定义角色”

但是,我可以从Azure UI控制台查看和分配此角色


我在实验室测试时,得到了与您相同的错误日志。我通过使用
-RoleDefinitionId
而不是
-RoleDefinitionName
来解决这个问题。下面的脚本适合我

$value=Get-AzureRmRoleDefinition
$a=$value |where {$_.Name -eq "Reader and Data Access"}

New-AzureRmRoleAssignment -ObjectId $app.ObjectId -Scope /subscriptions/$subscriptionID -RoleDefinitionId $a.Id

我没有Azure,但是当您尝试
Get-AzureRmRoleAssignment
@Matt是的,我可以使用
Get-AzureRmRoleDefinition
在powershell中看到此角色,并且我还可以看到已使用
Get-AzureRmRoleAssignment
列出了正在分配的角色。这是您能够创建的角色吗预定的?我问这个问题是因为我想知道名称中是否有尾随空格或隐藏字符(不允许这样做)。这不是预定义的角色。我从未创建过任何自定义角色。它将向ServicePrincipal或Application授予权限吗?它们都受支持。