Powershell help

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
}

}

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.

Hope it helps

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

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