header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Export Group Members to CSV
Last Post 02 Nov 2011 04:50 AM by swinney. 6 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Lee M TaylorUser is Offline
New Member
New Member
Posts:1
Avatar

--
05 May 2011 04:00 AM
    Hi

    I have around 500 groups listed in a CSV file, they are all in the same OU within Active Directory and I want to export the members of all of them to the same CSV, but I need the group name as a header and the description field of the group....eg;

    Group Name, Description
    Member1, Description
    Member2, Description

    etc etc etc

    I can do this exporting to a txt file, but using multiple rows, but am stuck with having it done as an array

    Thanks
    Lee
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    13 May 2011 01:12 AM
    Your quickest method might just be to create a seperate csv for each group, then merge them once completed. I'm not one for manual work, but a quick cut and paste will sort your query inside a minute.

    Rob
    cameronoveUser is Offline
    Basic Member
    Basic Member
    Posts:352
    Avatar

    --
    13 May 2011 07:40 AM
    It's a little unclear what you are asking for, it sounds like you want your data grouped.  However, you are saying that you want as headers in one (1) csv file the Group Name and Description for about 500 groups.  Are you asking to have 1000 header fields in your csv?  It seems that would be a bit confusing.  Personally I'd create a CSV file with 4 header fields:

    GroupName,GroupDescription,MemberName,MemberDescription

    Each subsequent row would contain all of that information.  Within Execl you could group the information for viewing purposes.  The script to do that would be this:

    $GroupInfo = '' | Select 'Group Name','Group Description','Member Name','Member Description'
    $AllGroups = @()
    $MyGroups = Get-QADGroup -SearchRoot "domain.local/geo location/Universal Groups" -DontUseDefaultIncludedProperties  -IncludedProperties Name,Description,Member | select Name,Description,Member
    foreach($Group in $MyGroups){
       
    $GroupInfo.'Group Name' = $Group.Name
       
    $GroupInfo.'Group Description' = $Group.Description
       
    foreach($Member in $Group.Member){
           
    $User = Get-QADUser $Member -DontUseDefaultIncludedProperties -IncludedProperties Name,Description | select Name,Description
           
    $GroupInfo.'Member Name' = $User.Name
           
    $GroupInfo.'Member Description' = $User.Description
           
    #it takes a while to go through a lot of goups...this just lets you watch so you don't think it's broke and cancel it.
            $GroupInfo | select 'Group Name','Group Description','Member Name','Member Description'
           
    $AllGroups += $GroupInfo | Select 'Group Name','Group Description','Member Name','Member Description'
        }
    }

    $AllGroups | Export-Csv allginfo.csv -NoTypeInformation #Export all that group info to csv file.

    evaporatedUser is Offline
    New Member
    New Member
    Posts:17
    Avatar

    --
    23 May 2011 08:02 AM
    I was trying to use this script, but am getting an error on the "get-QADGroup" cmdlet. This is not in my list of cmdlets. How would I add it?
    cameronoveUser is Offline
    Basic Member
    Basic Member
    Posts:352
    Avatar

    --
    23 May 2011 08:57 AM
    You need to install the Quest cmdlets found here:

    http://www.quest.com/powershell/act...erver.aspx
    evaporatedUser is Offline
    New Member
    New Member
    Posts:17
    Avatar

    --
    23 May 2011 09:59 AM
    Thank you so much, Cameronove!
    swinneyUser is Offline
    New Member
    New Member
    Posts:29
    Avatar

    --
    02 Nov 2011 04:50 AM
    This script is great! Is there a way to get it to search the root and any OU's under it?

    example= -SearchRoot "domain.local/groups" #there are many sub OU's that I would like it to go through as well


    thanks
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer