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)
ASKER