none
List all groups and users displaying 1 row per group RRS feed

  • Question

  • Hi everyone,

    I've tried by many way to get pretty similar result as this subject "Expand members array for get-adgroup to a single row seperated by semicolon" (sorry for that, unable to use hyperlink).

    I turn in round.

    I would like to get a result like this : 

    group1;user1; user2; user3; user4

    group2;user1; user3

    My constraint is to get this result with user list sorted and not displaying disabled user. 1 Single row per Group.

    Here is my code : 

    $ExclusionUsers = Get-ADUser -Filter {Enabled -eq $false} | Sort-Object Name | select Name

    $Groups = Get-ADGroup -Filter * -SearchBase "OU=yourOU,DC=msoft,DC=com" | Sort-Object Name `
    | foreach-object {(get-adgroupmember -identity $_.name | Sort-Object Name | Select -expand Name) -join ';'} #| Export-Csv $File1 -encoding "unicode"

    echo $groups

    I don't find the way not to display disabled users, and to start row with the group name.

    Thank you very much for help or comments.

    Thursday, July 27, 2017 1:14 PM

Answers

  • I don't recommend that kind of output because it is harder to parse after-the-fact.

    I recommend this kind of output instead:

    groupname  username1
    groupname  username2

    ...etc.

    In this way you can easily output to CSV and import into a spreadsheet for analysis (cross-tabulation, etc.).


    -- Bill Stewart [Bill_Stewart]

    Thursday, July 27, 2017 1:41 PM
    Moderator

All replies

  • I don't recommend that kind of output because it is harder to parse after-the-fact.

    I recommend this kind of output instead:

    groupname  username1
    groupname  username2

    ...etc.

    In this way you can easily output to CSV and import into a spreadsheet for analysis (cross-tabulation, etc.).


    -- Bill Stewart [Bill_Stewart]

    Thursday, July 27, 2017 1:41 PM
    Moderator
  • Hi bill,

    I know but I appreciate this notation because I use the output (text file) with php server and  php expode method.

    This is easier for me and my php script aldready fits that kind of display.

    thank you for this recommandation

    Thursday, July 27, 2017 1:48 PM
  • Hi all,

    Does anyone have an idea ?

    Thanks

    Monday, August 7, 2017 11:39 AM