我一直试图使用PowerShell代码在Azure中的多个资源上分配多个角色,原因是我们没有为了成本而使用custome角色,下面是我试图编写代码的方式。
$RGs = Import-CSV -Path "C:\input\RBAC-RGs.csv"
$Roles = Import-CSV -Path "C:\input\RBAC-Roles.csv"
$AZAD = Get-AzADGroup -SearchString "Group-Name" #Get Group name Object ID
ForEach ($Group in $RGs) {
Get-AzResourceGroup -Name "$RGs.ResouceGroups" #Get Resource Group resource ID for scope
New-AzRoleAssignment -ObjectId "$AZAD.id" `
-RoleDefinitionName "Storage Account Contributor" `
-Scope "/subscriptions/{subscripotionid}/resourceGroups/resource-group-name"发布于 2020-09-14 11:59:24
这是可能的。您的脚本中只存在一个PowerShell问题:
New-AzRoleAssignment -ObjectId "$AZAD.id" =>,您必须省略这里的引号,或者将属性访问包装为:"$($AZAD.id)"。
https://stackoverflow.com/questions/63881569
复制相似问题