Link to home
Start Free TrialLog in
Avatar of aroddick
aroddickFlag for Australia

asked on

Active Directory Powershell ADGroup Report incl. 'Description Field'

Hi All,

Huge thanks in advance for your help, Experts Exchange has almost literally never let me down.

I'm grappling with a powershell script intended to produce a report that exports to CSV all of the Groups within an OU as well as each groups memberships. The other catch is that I need the 'Description' field to come out with the report. In my mind ideally the csv resemble something akin to:

GroupName, MemberName, GroupDescription
Contoso Admins, Joe Bloggs, "Admins of the Contoso Network"
Contoso Admins, John Smith, "Admins of the Contoso Network"
Contoso Finance, John Doe, "Contoso Finance Staff"

OR

GroupName, MemberName, GroupDescription
Contoso Admins, Joe Bloggs, John Smith, Jane Doe, "Admins of the Contoso Network"
Contoso Finance, John Doe, "Contoso Finance Staff"

I'm hesitant to even post my recent attempts, I'm sure they are fairly shameful.

Any suggestions are very welcome.

Thank you again,

Adam
Avatar of aroddick
aroddick
Flag of Australia image

ASKER

If it helps - I've done an 'Export List' of the OUs in question to a csv which includes the Group 'friendly' Name and the Description so...

Is there is a way to parse the contents of one of those csv files through to a Get-ADMember command somehow to generate something useful?
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Get-ADGroup -filter * -SearchBase $OU -Properties description | select name,description | % { 
  $OU="OU=Security Groups,OU=Australia,DC=contoso,DC=com,DC=au"
  $gname = $_.name
  $gdesc = $_.description
  Get-ADGroupMember $gname | Select @{n="GroupName";e={$gname}},@{n="MemberName";e={$_.name}},@{n="GroupDescription";e={$gdesc}} } | Export-CSV C:\Final.csv -notype

Open in new window


Much simpler than the methods I was playing with. I've just added a -SearchBase filter to limit to the OU I want to scan. Perfecto.

Thank you very much mate, sincerely appreciated!

Adam
Perfect mate. Sincerely appreciated.