Forum Discussion
printscreen
Jan 14, 2021Brass Contributor
Power shell script which shows list of RBAC role, Azure resource for all Users in Azure
Hi. I'm pretty new to PowerShell and trying out things. I'm trying to form a PowreShell script which shows list consists of Azure resource name, RBAC role, Username against it( all users included even in groups). I got to know that, we can see all users in group with this Get-AzAdGroupMember command. I tried to tweak for what I've found here in community into below, but I'm hitting to an error as shown below, I'm sure i was doing some syntax/silly mistakes, Can anyone please help me here?
ForEach ($Resource in Get-AzResource) {
$RoleAssignments=Get-AZRoleAssignment -ResourceGroupName $Resource.ResourceGroupName -ResourceName $Resource.Name -ResourceType $resource.type
$new=Get-AzADGroupMember -DisplayName $RoleAssignments.DisplayName
foreach ($new in $RoleAssignment){
ForEach ($RoleAssignment in $RoleAssignments){
$Resource | Select-Object @{Name="Azure Resource name";Expression={$Resource.Name}},
@{Name="SignInName";Expression={$RoleAssignment.SignInName}},
@{Name="DisplayName";Expression={$RoleAssignment.DisplayName}},
@{Name="RoleDefinitionName";Expression={$RoleAssignment.RoleDefinitionName}}
}
}
error message:
Get-AzADGroupMember : A parameter cannot be found that matches parameter name 'DisplayName'.
At line:3 char:30
At line:3 char:30
}
- AndySvintsSteel Contributor
Hello printscreen,
You are using wrong parameter name it should be GroupDisplayName not DisplayName
$new=Get-AzADGroupMember -GroupDisplayName $RoleAssignments.DisplayName
Hope that helps.