Posts

Showing posts from June, 2021

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