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

%3CLINGO-SUB%20id%3D%22lingo-sub-2061672%22%20slang%3D%22en-US%22%3EPower%20shell%20script%20which%20shows%20list%20of%20RBAC%20role%2C%20Azure%20resource%20for%20all%20Users%20in%20Azure%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2061672%22%20slang%3D%22en-US%22%3E%3CP%3EHi.%20I'm%20pretty%20new%20to%20PowerShell%20and%20trying%20out%20things.%20I'm%20trying%20to%20form%20a%20PowreShell%20script%20which%20shows%20list%20consists%20of%20Azure%20resource%20name%2C%20RBAC%20role%2C%20Username%20against%20it(%20all%20users%20included%20even%20in%20groups).%20I%20got%20to%20know%20that%2C%20we%20can%20see%20all%20users%20in%20group%20with%20this%20Get-AzAdGroupMember%20command.%20I%20tried%20to%20tweak%20for%20what%20I've%20found%20here%20in%20community%20into%20below%2C%20but%20I'm%20hitting%20to%20an%20error%20as%20shown%20below%2C%20I'm%20sure%20i%20was%20doing%20some%20syntax%2Fsilly%20mistakes%2C%20Can%20anyone%20please%20help%20me%20here%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CSPAN%3EForEach%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3E%24Resource%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ein%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EGet-AzResource%3C%2FSPAN%3E%3CSPAN%3E)%26nbsp%3B%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24RoleAssignments%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3EGet-AZRoleAssignment%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ResourceGroupName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24Resource%3C%2FSPAN%3E%3CSPAN%3E.ResourceGroupName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ResourceName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24Resource%3C%2FSPAN%3E%3CSPAN%3E.Name%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ResourceType%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24resource%3C%2FSPAN%3E%3CSPAN%3E.type%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24new%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3EGet-AzADGroupMember%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-DisplayName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24RoleAssignments%3C%2FSPAN%3E%3CSPAN%3E.DisplayName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eforeach%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3E%24new%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ein%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24RoleAssignment%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EForEach%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ignInName%22%3C%2FSPAN%3E%3CSPAN%3E%3B%3C%2FSPAN%3E%3CSPAN%3EExpression%3C%2FSPAN%3E%3CSPAN%3E%3D%7B%3C%2FSPAN%3E%3CSPAN%3E%24RoleAssignment%3C%2FSPAN%3E%3CSPAN%3E.SignInName%3C%2FSPAN%3E%3CSPAN%3E%7D%7D%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%40%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3EName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22DisplayName%22%3C%2FSPAN%3E%3CSPAN%3E%3B%3C%2FSPAN%3E%3CSPAN%3EExpression%3C%2FSPAN%3E%3CSPAN%3E%3D%7B%3C%2FSPAN%3E%3CSPAN%3E%24RoleAssignment%3C%2FSPAN%3E%3CSPAN%3E.DisplayName%3C%2FSPAN%3E%3CSPAN%3E%7D%7D%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%40%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3EName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22RoleDefinitionName%22%3C%2FSPAN%3E%3CSPAN%3E%3B%3C%2FSPAN%3E%3CSPAN%3EExpression%3C%2FSPAN%3E%3CSPAN%3E%3D%7B%3C%2FSPAN%3E%3CSPAN%3E%24RoleAssignment%3C%2FSPAN%3E%3CSPAN%3E.RoleDefinitionName%3C%2FSPAN%3E%3CSPAN%3E%7D%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3Eerror%20message%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CDIV%3E%3CSPAN%3EGet-AzADGroupMember%20%3A%20A%20parameter%20cannot%20be%20found%20that%20matches%20parameter%20name%20'DisplayName'.%3CBR%20%2F%3EAt%20line%3A3%20char%3A30%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2061672%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPower%20shell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Epowershell%20script%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2065379%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20shell%20script%20which%20shows%20list%20of%20RBAC%20role%2C%20Azure%20resource%20for%20all%20Users%20in%20Azure%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2065379%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F923986%22%20target%3D%22_blank%22%3E%40printscreen%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EYou%20are%20using%20wrong%20parameter%20name%20it%20should%20be%20%3CSTRONG%3EGroupDisplayName%3C%2FSTRONG%3E%20not%20DisplayName%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%20%20%20%20%24new%3DGet-AzADGroupMember%20-GroupDisplayName%20%24RoleAssignments.DisplayName%20%0A%20%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Faz.resources%2Fget-azadgroupmember%3Fview%3Dazps-5.3.0%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EReference%3C%2FA%3E.%3C%2FP%3E%3CP%3EHope%20that%20helps.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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}},
        @{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
   }
1 Reply

Hello @printscreen,

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

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

Reference.

Hope that helps.