This get the SharePoint groups that a user is a member of for a given site. This uses the user's login name for a comparison.
#This power shell smippet list the members of a SharePoint site
$web = Get-SPWeb https://xxxx
$groups = $web.sitegroups
$UserName = "PSNS\psc28010b"
foreach ($grp in $groups)
{
foreach ($user in $grp.users)
{
if($user.LoginName -eq $UserName){
"Group: " + $grp.name | out-file "F:\temp\groups.txt" -append
" User: " + $user | out-file "F:\temp\groups.txt" -append
}
}
}