Get a list of all user from Azure Ad connected device with user type information

Hriday Saha 11 Reputation points

i have a few m365 users remaining with administrator privileges rather than standard users in Azure ad joined devices. so is there any way to get the list of total users with administrator/standard privileges?


Can I change all user types from administrator to standard?

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
14,748 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
2,726 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Konstantinos Passadis 5,266 Reputation points

    Hello @Hriday Saha !

    I understand you want to export your Admins OR change them to regular users

    It is possible and i have verified it with Powershell

    Remember this script will probably not run on PS7 so use Powershell 5 in Admin Mode

    Install-Module AzureAD

    Install-Module MSOnline


    # Get all directory roles
    $roles = Get-AzureADDirectoryRole
    # Get all users
    $users = Get-AzureADUser
    # Iterate over each user
    foreach ($user in $users) {
      # Get user membership
      $memberships = Get-AzureADUserMembership -ObjectId $user.ObjectId
      # Create a custom object to store user info and role
      $userRole = New-Object -TypeName PSObject -Property @{
          UserPrincipalName = $user.UserPrincipalName
          DisplayName = $user.DisplayName
          Role = @()
      # Check if user has a role
      foreach ($membership in $memberships) {
          $role = $roles | Where-Object {$_.ObjectId -eq $membership.ObjectId}
          if ($role) {
              $userRole.Role += $role.DisplayName

    You can add this at the end to display only those who have roles

    if ($userRole.Role) {

    If you want to change i suggest do not do it from Powershell . Use the list and make adjustments

    Also remember Save the Script as myscript.ps1 and run it as c:\works> .\myscript.ps1 | FL

    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!


  2. Konstantinos Passadis 5,266 Reputation points

    Hello @Hriday Saha !

    Do you thin that this tool can help you ?

    I just found it and immediately i though of your issue

    Please verify !

    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!


    0 comments No comments