+ Reply to Thread
Results 1 to 8 of 8

Sort Active Directory users by group

  1. #1
    Registered User
    Join Date
    03-25-2019
    Location
    Brussels, Belgium
    MS-Off Ver
    2016 Pro
    Posts
    4

    Sort Active Directory users by group

    Hi,

    I made a Powershell script to extract all groups and users. The output is a .csv file that looks like this.

    HTML Code: 
    I separate them them like this.
    Data > text to column > Delimited by Comma

    Group "member" enabled
    Admin Pietsje Overmars True
    Admin Reinder Wortel True
    Admin Karima Hazewinkel False
    HR Wouterina Keulemans True
    HR Phaedra Lugt True
    IT Marlin Moens False
    IT Manuel Dongelmans True

    I want the output to look like this with the users that are disabled (False) in red or strike-through:

    Admin HR IT
    Pietsje Overmars Wouterina Keulemans Marlin Moens
    Reinder Wortel Phaedra Lugt Manuel Dongelmans
    Karima Hazewinkel

    I only get something that is remotely similar to what I want when I put both Group and Member under ROWS in a PIVOT-TABLE. When I ad enabled to filter I can select True or False which is nice but not really necessary. They should be next to each other (blank) and Grand Total should be gone.
    Attached Images Attached Images
    Last edited by denisuu; 03-25-2019 at 06:26 AM. Reason: Added additional info

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Sort Active Directory users by group

    You could do something like:

    Use Power Query to import your CSV data, and index by Group:

    Please Login or Register  to view this content.
    Load this query to the Data Model. Add a couple of measures:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Now you can use CUBEVALUE formulae to display the names:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Capture.png


    Finally, use a CUBEVALUE formula in conditional formatting, and format to suit:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See https://excel.solutions/xlf_1269773/ for a worked example file.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    03-25-2019
    Location
    Brussels, Belgium
    MS-Off Ver
    2016 Pro
    Posts
    4

    Re: Sort Active Directory users by group

    Thanks, I've never used Power Query (Networking Student). I'll give it a try tomorrow, I have to be honest I don't understand what's going on at all. I thought this would be a lot simpler.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,848

    Re: Sort Active Directory users by group

    Hello denisuu and Welcome to Excel Forum.
    Here is a formula based option that assumes you already have the data in Excel as shown below the statement "I separate them them like this":
    1. Populate row 1 with the headers Admin, HR and IT
    2. Populate the rows under the headers using: =IFERROR(INDEX($B$2:$B$8,AGGREGATE(15,6,(ROW(A$2:A$8)-ROW(A$1))/($A$2:$A$8=E$1),ROWS(A$1:A1))),"")
    3. Conditionally format the range using: =NOT(INDEX($C$2:$C$8,MATCH(E2,$B$2:$B$8,0)))
    For future reference you will usually get faster responses if you upload a file by clicking on the Go Advanced button below the Quick Reply window then scrolling down to Manage Attachments to open the upload window.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Registered User
    Join Date
    03-25-2019
    Location
    Brussels, Belgium
    MS-Off Ver
    2016 Pro
    Posts
    4

    Re: Sort Active Directory users by group

    Thanks!

    I'm not sure if I understand this forumula, how do you even find something like that haha. I can easily make the headers if it's only for those 3 groups Admin, IT and HR but in the real example the powershell script can output 78 to 3600 groups... So I would need to automate merging groupnames.

    It seems I can already apply excel formatting through powershell too but my knowledge doens't reach that far. Next time I'll upload an excel file! This weekend I'll make some fake users and groups in Active Directory and then export them to an excel so you can see what I try to achieve.

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,848

    Re: Sort Active Directory users by group

    This will automate the displaying of headers:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Select cell E1,
    Paste the formula into the formula bar,
    Drag the fill handle over to cell H1.
    Let us know if you have any questions.

  7. #7
    Registered User
    Join Date
    03-25-2019
    Location
    Brussels, Belgium
    MS-Off Ver
    2016 Pro
    Posts
    4

    Re: Sort Active Directory users by group

    Inserting that forumula into E1 gives e:

    There's a problem with this formula.

    Not trying to type a forumal?
    When the first charcter is an equal(=) or minus (-) sign, Excel thinks it's a formula.

    you type: =1=1, cell shows : 2

    To get around this, type an apostrphe (') firts:

    you type: '=1=1, cell shows: =1+1

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,848

    Re: Sort Active Directory users by group

    I don't understand why that should be so. Here is the file with the formula applied.
    Let us know if you have any questions.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 04-18-2014, 05:54 PM
  2. Pull Active Directory Group Information into Excel
    By jam92102 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-20-2014, 04:32 PM
  3. Replies: 0
    Last Post: 09-05-2013, 10:00 AM
  4. How to add user to active directory group
    By Silencer001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2013, 04:45 PM
  5. Active Directory Help
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-26-2011, 07:27 AM
  6. Get User Name - Active Directory
    By jai2808 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2007, 05:20 AM
  7. Active Directory References? help...
    By Judith in forum Excel General
    Replies: 1
    Last Post: 10-12-2006, 04:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1