Monday, January 08, 2018

Quick tip: finding all users with Dynamics 365 Service Administrator role in Office 365 tenant with PowerShell

Unfortunately the Office 365 Admin Portal, does not contain a predefined view to show all users who have the Dynamics 365 Service Administrator role – this role allows you to manage Dynamics 365 at tenant level (See Use the service admin role to manage your tenant for more details). But luckily you can also retrieve this information using PowerShell.

First make sure that you install the different prerequisites as outlined in Connect to Office 365 PowerShell – next open Windows Azure Active Directory Module for Windows PowerShell. To connect to Office 365, simply type connect-msolservice . Get-MsolRole will give you a list of all administrator roles. You will see that the internal role name which is listed is still "CRM Service Administrator". The last line will export all users with this role to a CSV file

 get-msolrole | select name, description  
 $role = get-msolrole -rolename "CRM Service Administrator"  
 get-msolrolemember -roleobjectid $role.objectid | export-csv d:\temp\serviceadmins.csv  

No comments: