pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


powershell get list of AD groups for a given user
Posted by Anonymous on Thu 1st Aug 2024 16:43
raw | new post

  1. queryuser="siegfried.wulsch" powershell -Command '(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$("$env:queryuser")))")).FindOne().GetDirectoryEntry().memberOf' | sed -E 's/CN=([^,]+),(.*)/groupname="\1" # \2/g' ; echo $?

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at