Solved

Active Directory Powershell ADGroup Report incl. 'Description Field'

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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