get list of AzureDirectory roles that assigned for a specific user by powershell

sarmed nazar 71 Reputation points
2021-10-15T09:26:03.41+00:00

Hi Support

I would like to get a list of AzureDirectory roles that assigned to a specific user by powershell .. i tried many commands but keep getting the error :

Get-AzRoleAssignment -SignInName "xxxxx@永爱不变 .com"
Get-AzRoleAssignment : Object reference not set to an instance of an object.
At line:1 char:1

  • Get-AzRoleAssignment -SignInName "xxx@永爱不变 .com"
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : CloseError: (:) [Get-AzRoleAssignment], NullReferenceExceptio
    n
  • FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.GetAzureRoleAssignmentComm
    and

I ran connect-azureAD before running the command above.

my nex question is how can i compare or copy the azuredirectory assigned role from one user to another user? the roles are administrative azure roles.
we have 5 admins and when a new admin account is being created so its useful to copy the same roles from one admin to another admin as each admin has many roles.

Best regards
Sam

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Santillan 197 Reputation points
    2021-10-15T12:46:55.79+00:00

    You need to use Connect-AzAccount from Az modules instead of Connect-AzureAD from the AzureAD module.

    GOfahYm.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.