Solved

Active Directory Powershell ADGroup Report incl. 'Description Field'

Posted on 2014-03-19
4
2,028 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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A procedure for exporting installed hotfix details of remote computers using powershell
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
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 show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

911 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

15 Experts available now in Live!

Get 1:1 Help Now