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
Connect-AzureAD
# 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
}
}
$userRole
}
You can add this at the end to display only those who have roles
if ($userRole.Role) {
$userRole
}
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!
Regards