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 install OpenVPN server on Raspberry Pi

How to restart VirtualBox VM to certain snapshot via Ubuntu Terminal