If you have any reason to communicate with your site owners, this script might be handy.
A few uses could be:
- Communicate policy changes as they relate to SharePoint Site Owners
- Communicate outage notifications to your site owners
- Communicate upcoming training opportunities to your site owners.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $logfile = "c:\temp\SPOwnerEmailList_$(get-date -format `"yyyymmdd_hhmmtt`").txt" $webapp = get-spwebapplication http://yourURL.com $sites = $webapp.sites $email = @("") #this sets up an empty array foreach ($site in $sites) { $weblist = $site.allwebs foreach ($web in $weblist) { $owners = $web.associatedownergroup foreach ($owner in $owners.users) { write-host "$($owner.email) - $($web.AssociatedOwnerGroup.Name)" $email = $email + $owner.email.ToLower() #this add's the current email address to the array } $web.dispose() } $site.dispose() } #Sort the array and remove duplicates: $email = $email | select -uniq | sort foreach ($m in $email) { "$m;" | out-file -filepath $logfile -append } #this just outputs how many email addresses there were to the screen: $email | measure
The script creates a text file and it’s fairly easy to copy-> paste the results to Outlook.
Thanks, It works well except when there are more than one “Owner” (Full Control) Groups in the same site, it only show one.. do you know why? Thanks