Discover All Teams Groups Owners and Admins- Powershell

Discover All Teams Groups Owners and Admins- Powershell

The Below PowerShell Script was created to not only identify all Teams / SharePoint and MS Group Owners and Admins - but to export a Report on these Users. I recommend using Azure Access Reviews to securely monitor and review these groups periodically. I have a nice post on Azure Access Reviews and the simplicity of using this function in Identity Governance. You need the newest PS Module and the the newest PNP Module .. But ith this script- you can create a Logic app to run the query and automatically send out the information for the Admins to review 'WHO' is the owner of Groups, Teams, Channels, SharePoint Sites and Distro Groups.

Happy Admin -ing Also- Happy Hinting.

-David J DeLorge

####### Delorge DJ Script 10/29/2021


$Cred = Get-Credential

Connect-PnPOnline -Url $Site.Url -Credentials $Cred

#Get All Site Collections?

$Sites = Get-PnPTenantSite

Disconnect-PnPOnline

#Loop through each Site Collection

ForEach ($Site in $Sites) {

??Write-host "Processing data for $Site.Url"?

??Connect-PnPOnline -Url $Site.Url -Credentials $Cred

??#Get Site Collection Administrators??

??$Siteadmins= Get-PnPSiteCollectionAdmin

??Foreach($Siteadmin in $Siteadmins) {

????If ($siteadmin.Email -ne ''){

??write-host $Site.Url,$Siteadmin.email,$Siteadmin.Title???Select-Object $Site.Url,$Siteadmin.Email,$Siteadmin.Title | Export-CSV C:\Temp\Mikesbullshit.csv } }

??Disconnect-PnPOnline??

}


要查看或添加评论,请登录

Dr. David Joseph DeLorge的更多文章

社区洞察

其他会员也浏览了