Powershell help


(K Papalia) #1

Is there a powershell script that will allow me to get a list of members in a SharePoint team site including their email address? I found this but I don’t know how to add script to get the email addresses

$site = Get-SPSite
$web = $site.OpenWeb()
$groups = $web.sitegroups

foreach ($grp in $groups) {
"Group: " + $grp.name;
$groupName = $grp.name

foreach ($user in $grp.users) {
		"User: " + $user.name
		write-host "User " $user.UserLogin   -foregroundcolor red
}

}


(Wade Blakeman) #2

Each time someone creates a team site it automatically creates an o365 group for that site and which has all the members and stays up to date with changes. Check out this site for a powershell script to list o365 groups and members of those groups.

https://gallery.technet.microsoft.com/office/How-to-get-all-the-members-4d75ec9e

Hope it helps


(Justin Anzelc) #3

This works for us.
$site = get-spweb -identity “fqdn”
get-spuser -web $site | select Name,Email


(system) #4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.