Power shell script which shows list of RBAC role, Azure resource for all Users in Azure

Brass Contributor

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}},
error message: 
Get-AzADGroupMember : A parameter cannot be found that matches parameter name 'DisplayName'.
At line:3 char:30
1 Reply

Hello @printscreen,

You are using wrong parameter name it should be GroupDisplayName not DisplayName

    $new=Get-AzADGroupMember -GroupDisplayName $RoleAssignments.DisplayName 


Hope that helps.