PowerShell Script to List All Users in All Groups

also check http://falakmahmood.blogspot.se/2012/05/how-to-loop-through-user-profiles-in.html#.UhSsy5L0FqU

$site = Get-SPSite http://yourservername/sites/yoursitecollection 

$groups = $site.RootWeb.sitegroups

foreach ($grp in $groups) {"Group: " + $grp.name; foreach ($user in $grp.users) {"  User: " + $user.name} }

$site.Dispose()

#
to view domain accounts and email address,. add:
{"  User: " + $user.name; "  User: " + $user.email; "  User: " + $user.userlogin}

Mention:

To get users directly assigned to a site (SPWeb) or to any object (list, item, etc) there are three properties to check: .Users, .AllUsers and .SiteUsers.

SPWeb.Users gets the collection of user objects that are explicitly assigned permissions in the Web site. It will not return users who have access through a group.

SPWeb.AllUsers gets the collection of user objects that represents all users who are either members of the site collection or who have browsed to the site as authenticated members of a domain group in the site.

SPWeb.SiteUsers gets the collection of all users that belong to the site collection.

So in PowerShell:

Get-SPWeb http://intranet.contoso.com | Select Users

Get-SPWeb http://intranet.contoso.com | Select AllUsers

Get-SPWeb http://intranet.contoso.com | Select SiteUsers
PowerShell Script to List All Users in All Groups