List of users in a SharePoint Site 2013

To get the list of users in a SharePoint 2013 site collection, execute the following Power Shell commands.
 
 
$site = Get-SPSite http://mysite/sites/TestSite

$groups = $site.RootWeb.sitegroups

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

$site.Dispose()