Forum Discussion
Bhavpreet Bains
Sep 28, 2018Iron Contributor
List all Site Collection Admins Powershell
Hello, I am trying to get all site collection admin for the sites in the tenant using Powershell. However, the cmdlet Get-SPOSite fetches only the primary site collection admins. The only way to ...
Alex Carlock
Jan 30, 2020Iron Contributor
bmartin921, Thanks for the details and the thoughts. Unfortunately, I'm in the same boat as @Bhavpreet Bains. The commands work to add and remove Site Collection Admins even if you're not a site collection admin, but they cannot VIEW the existing site collection admins unless you are also a site collection admin.
I'm surprised Microsoft hasn't updated the commands to allow that functionality for Office 365 Global Admins and SharePoint Admins. Another option is for MSFT to build in such an audit report into the Office 365 or SharePoint admin sites.
My next option is to write a script that does the following:
- Pull the list of admins
- If I get results, great
- If I get no results add myself as an admin
- Pull the list of admins
- Remove my admin access
It's messy, but it should do the trick.
Cissong
Dec 10, 2021Brass Contributor
Hello Alex Carlock were you able to get a script to get all the sites with site admins
- Alex CarlockDec 10, 2021Iron ContributorI only used the script I posted above. I never found or created another script that can do it without temporarily adding admin access and then removing it. It's a little messy, but it works.