Avatar of Shain Allen
Shain AllenFlag for United States of America

asked on 

how to figure out what Roles a user requires to run some Powershell cmdlets for Exchange Online and get those roles assigned to said user

so I recently have been working around the task of thinning out the number of inactive DL's we have in O365 and I stumbled upon this set of 3 scripts made by u/ascIVV on reddit which was posted on several subreddits. and after going through the script to make sure it was safe and that I understood how it works so I could fix and and tune it for our needs if required I then tested it and it worked, though I was using a global admin account which is not entirely best practice I have heard for scripts that run regularly on their own, so I decided I would make an account that had the bare minimum required permissions to run the script, however upon making this account and trying to run it with just the Exchange Administrator Role I found out that the script would throw some errors so I assume I am missing some roles. so that leads me to my question, what would be the best way to go about figuring out what roles are required for the cmdlets being used in a script and then assigning them to a user.

here is the GitHub repo where the original script lives ascivv/DLActivityScripts (github.com) 
PowershellExchangeMicrosoft 365

Avatar of undefined
Last Comment
Vasil Michev (MVP)
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Shain Allen
Shain Allen
Flag of United States of America image


so I have tried Get-ManagmentRole before but the roles that it shows me are always roles that I can't find in my Admin Center, is there anywhere else that these roles could be found or perhaps a cmdlet for assigning these roles?
Those are Exchange roles, you wont find them in the Admin center. The article shows you how to find the corresponding Exchange Role Groups that contain the given role, you can assign those from within the EAC as needed, or create direct role assignments via PowerShell. Follow the links within the article for more detail.

Exchange is the server side of a collaborative application product that is part of the Microsoft Server infrastructure. Exchange's major features include email, calendaring, contacts and tasks, support for mobile and web-based access to information, and support for data storage.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo