Running this script will generate a report, which displays the list of site collections that has multiple site collection administrators and will also display the total number of users who have access to those site collections.
- Add - PSSnapin microsoft.sharepoint.powershell - ErrorAction SilentlyContinue
- Add - Content "Sites.csv" - Value "SiteCollection Name,SiteCollection URL, SiteCollection Administrators, Users Count,Usage in MB"
- $webApp = Get - SPWebApplication
- foreach($webapps in $webapp)
- {
- foreach($SiteCollection in $webApps.Sites)
- {
- $url = $SiteCollection.Url
- $webs = Get - SPWeb $URL[boolean] $WriteToFile = $true
- $weburl = $SiteCollection.OpenWeb()
- $siteowner = ""
- foreach($siteAdmin in $weburl.SiteAdministrators)
- {
- $siteowner = $siteAdmin.DisplayName + "|" + $siteowner
- }
- foreach($web in $webs)
- {
- #Grab all users in the site collections
- $siteUserCnt = $web.AllUsers.Count
- $Siteurl = $web.Url
- $siteTitle = $web.Title
- $site = Get - SPSite $Siteurl
- $siteusage = $site.Usage.Storage / 1 MB
-
- Add - Content - Path "Sites.csv" - Value "$siteTitle,$Siteurl,$siteowner,$siteUserCnt,$siteusage"
- $web.Dispose()
- }
- }
- }
Thanks for using this script. Happy SharePointing.