Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Monday, January 23, 2012

How to list the group membership of a user with PowerShell

Here is a nice example of a one liner.

(Get-ADUser –filter “Name –like ‘Adm*’” –Properties MemberOf).MemberOf

This will return the FQDN of the groups the user is a member of.  The first portion need to execute first and that is why we placed it inside of parenthesis.  We then had to specifically tell PowerShell to give us the MemberOf property.  Once the first portion of the command completes, we have an object to work with.  Now we just simply ask PowerShell to provide us with the MemberOf property.

No comments: