PowerShell to list Active Directory groups membership

Problem

I need a list of AD groups of my colleague's who has left the company so that I can request for similar groups membership.

Solution

Run the following command on Windows PowerShell Console or PowerShell ISE:

(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf

or

(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=YourWindowsLogin))")).FindOne().GetDirectoryEntry().memberOf

Comments

Popular posts from this blog

How to search Active Directory group members using Windows 10 built-in tools

How to check and reload PAC (Proxy Auto Configuration) file on Windows