How can I generate a list of the security groups a set of users belong to?
Extend your Get-ADUser
line:
$getmembership = Get-ADUser $User -Properties MemberOf | Select -ExpandProperty memberof | Get-ADGroup -Properties name | Where { $_.GroupCategory -eq 'Security' } | Select -ExpandProperty Name
This will feed the DN of the Group to Get-ADGroup
to retrieve additional properties, then filter on group category and select the name of the group (instead of the DistinguishedName).