Solved

Active Directory Powershell ADGroup Report incl. 'Description Field'

Posted on 2014-03-19
4
1,951 Views
Last Modified: 2014-03-19
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
0
Comment
Question by:aroddick
  • 3
4 Comments
 
LVL 2

Author Comment

by:aroddick
ID: 39941520
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?
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 39941534
This is pretty simple.  The key here is using calculated properties.
Get-ADGroup -filter * -Properties description | select name,description | % { 
  $gname = $_.name
  $gdesc = $_.description
  Get-ADGroupMember $gname | Select @{n="GroupName";e={$gname}},@{n="MemberName";e={$_.name}},@{n="GroupDescription";e={$gdesc}} } | Export-CSV somefile.csv -notype

Open in new window

If you need to limit to a particular OU, you can use the -searchbase parameter of Get-ADGroup.  If you have multiple OUs to query, then you could either read those from a file, or create an array with them in it, and then pipe that array to a foreach loop for Get-ADGroup to act on.
0
 
LVL 2

Author Comment

by:aroddick
ID: 39941550
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
0
 
LVL 2

Author Closing Comment

by:aroddick
ID: 39941551
Perfect mate. Sincerely appreciated.
0

Join & Write a Comment

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now