Role call!

On a regular basis, you should be reviewing who holds roles in Office 365. Is everyone using the Company Administrator role? Well, you should just be giving the minimum required permissions. Here's a good way to extract the membership for all the roles. The extract makes it easy to give to people to review.

 $roles = Get-MsolRole
Foreach ($role in $roles) {
 $Filename = "C:\temp\"+$role.name+".csv"
 Get-MsolRoleMember -RoleObjectId $role.ObjectId | Export-CSV $Filename -NoTypeInformation
 }

All this code comes with the normal disclaimers, of course. Try this in a lab, if at all possible. You’re on your own here – there’s no warranty on this. If you use it, please leave a comment.