PowerShell: Get All Group-Membership of One User/Multiple Users

Earlier, I wrote a VBScript which can retrieve and enlist All Group-Membership of a given AD User. You can pass the desired Username as a parameter and execute the VBScript. That's it. The script will do the job and display the result. The same VBScript can be downloaded from h

4.2 Star
13,767 times
Add to favorites
Active Directory
E-mail Twitter del.icio.us Digg Facebook
  • Not getting nested groups?
    1 Posts | Last post August 30, 2018
    • This is listed as the powershell version of the older .vbs script.  It appears to work, but with the .vbs version I see all of the nested group memberships.  I don't seem to be getting that with the powershell version.  Is there something I'm missing?
  • Not getting Output
    2 Posts | Last post March 20, 2018
    • Hello, I'm hoping questions are still being anwered here...
      I am running this script and passing a csv file as input. It looks like it runs successfully, but the output file is blank. I beleive my csv file is formatted correctly. The first line of first column is  UserLoginID and the lines below that each contain a username. 
      I see that others have had this problem here, but I don't see a clear resolution listed. I'm running it on Windows Server 2008 R2 and running PS as admin. 
    • I was able to figure out how to run it. For some reason it does not work on the version of PS that comes on Server 2008 R2. I am able to run it from a Server 2012 box. 
      Here's another question...
      Has anyone tried to have the output dumped to a csv or Excel file? The text file formatting is nice and everything, but would be more useful to have it in a searchable and sortable spreadsheet.
  • No output
    5 Posts | Last post August 29, 2017
    • Hope you still answer questions about this :) :
      If i run the script i get the working please wait, but its not reading any users ? 
      And in the reportfile no users are showing up.
    • Right-Click PowerShell console and "Run as Administrator".
      For Multiple Users, if its not like the screenshot shown, please mail me a screenshot of the Powershell console & the input file when you execute the script.
      Let me see.
    • Thanks for helping me !
      On what mail adress can i contact you ?
      i uploaded the image on imgur aswell : http://imgur.com/a/S9G5p
    • Got it working on my own machine, think its the server version of powershell ?
    • PatrickvdZwart - What did you have to do to get it to work? I have the same setback. script runs very quicly and there is no output. 
  • getting error in Paranthesis
    1 Posts | Last post August 28, 2017
    • PS C:\users\kmanisa\desktop> .\Multiple_UserGroup_InputFile.ps1 -CSVFile "C:\Users\KmaniSA\Desktop\Book2.csv"
      Missing closing ')' in expression.
      At C:\users\kmanisa\desktop\Multiple_UserGroup_InputFile.ps1:11 char:1
      +  <<<< $UserName | Measure-Object).Count
          + CategoryInfo          : ParserError: (CloseParenToken:TokenId) [], ParseException
          + FullyQualifiedErrorId : MissingEndParenthesisInExpression
      and how to export to csv file this script,As we have not added the path here
      	[Parameter(Mandatory = $True)]
      Import-Module ActiveDirectory
      If ($UserName) {
      	$UserName = $UserName.ToUpper().Trim()
      	$Res = (Get-ADPrincipalGroupMembership 
      $UserName | Measure-Object).Count
      	If ($Res -GT 0) {
      		Write-Output "`n"
      		Write-Output "The User $UserName Is A 
      Member Of The Following Groups:"
      $UserName | Select-Object -Property Name, GroupScope, 
      GroupCategory | Sort-Object -Property Name | FT -A |
      Out-File "C:\Users\KmaniSA\Desktop\Book3.csv"
  • The script is wonderful but the ReportFile does not report anything
    2 Posts | Last post July 27, 2017
    • Running in Server 2008 R2, PS running as administrator.  Can you advice on that?  Thanks.
    • PS version is 2 0 1 1.  I run in server 2012 (PS version 4 0 1 1) and run like a charm.  Besides of update the PS, there something that I can do to run it on PS 2 0 1 1?  Thanks in advance.
  • Trusted Domains, Too?
    2 Posts | Last post June 27, 2017
    • I am having a devil of a time getting lists of users from Domain1 when they are members of groups in Domain2.  This script is exactly what I want, but it only searches the domain from which it is run against users in that domain.  Is there a way to search all groups in DOMAIN2 for DOMAIN1\UserA?
    • I have not added the feature for working from "Trusted" domains. In your situation, you have to execute the script from Domain 2 as well.
  • Update the same CSV file
    2 Posts | Last post February 17, 2017
    • Thanks for your script it work like a charm
      Is it possible to update the same csv file rather than create a new text file? I just want "group name" in the second column I don't need any other information 
      How can we export groups of computer rather than user?
      Thanks in Advance
    • I guess you mean the report file. By design, this script will generate a new report file each time you run it. That is how this script is written. If you have a powershell guy handy, you can ask him to modify the code section which generates the report.
  • output file blank
    2 Posts | Last post February 17, 2017
    • Hello, thanks for the script however when i run it i get no errors but the output file is blank, i created a CSV file to import and get no errors on this i changed the line at line 48 to load the domain i use as we have a few and when i load powershell it defaults to the main domain 
      Get-ADPrincipalGroupMembership -server "my domain" $UserName | Select name | FT -A | Out-File "Test2.txt"
      any ideas, thanks in advance 
    • That is by design. This script has not been written to run from another domain. You will have to log in to each respective domain to get the desired result.
  • All users ?
    4 Posts | Last post January 13, 2017
    • How can I use it to extract group membership information for all the users in AD ?
    • All Users in AD can be huge -- there can be millions and millions of User-Accounts in AD depending on how large the organization is. So, the best option I can suggest is to use an input file with selected users. 
    • As per your request, I have updated this publication with updated scripts.
      Please go ahead and download from here:
    • I got it done in this way
  • Run over a specific DC / Domain?
    2 Posts | Last post December 27, 2016
    • Could you tell us how to run this over a specific domain / DC? Thanks, Adrian R
    • Sorry, cant understand the question. Plz explain what exactly you mean.
1 - 10 of 12 Items