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 migrate SharePoint Online SPWeb with custom SPList form (PowerApps) and Flows

How to paginate SSRS Report to solve rendering performance issue on Internet Explorer

How to setup SharePoint Online Development Environment (Part 2)