List all groups and their descriptions for a specific user in Active Directory using PowerShell
active-directory, powershell
Solution
From `Get-ADPrincipalGroupMembership` manual:
The Get-ADPrincipalGroupMembership cmdlet returns a default set of ADGroup property values. To retrieve additional ADGroup properties pass the ADGroups objects produced by this cmdlet through the pipline to Get-ADGroup. Specify the additional properties required from the group objects by passing the -Properties parameter to Get-ADGroup.
So, let’s do it!
import-module activedirectory
$username = Read-Host 'Please enter Username!'
Get-ADPrincipalGroupMembership $username | Get-ADGroup -Properties * | select name, description
Also, in this case it should be enough to specify `name,description` instead of asterisk (`*`). If this is a performance issue, replace it. I am leaving it at asterisk because you might later change your mind about which properties you need.
Problem
I am trying to get the list of a specific user’s groups and the groups’ descriptions using PowerShell. ``` import-module activedirectory $username = Read-Host 'Please enter Username!' Get-ADPrincipalGroupMembership $username | select name, description ``` The description field returns blank.