I recently was on an engagement where I was able to successfully compromise a large list of user accounts. I wanted to leverage PowerShell to quickly see which groups these users are a part of to help me decide who to enumerate first.
I through the users into a text file and this is the PowerShell code I ended up using.
$users = Get-Content -path 'C:\tmp\users.txt' foreach($user in $users){ write-host "Group Membership for: " $user Get-ADPrincipalGroupMembership -Identity $user | Select name | ft -hidetableheaders write-host "______________________________" }