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

sarmed nazar 56 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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,360 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,441 questions
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