+ Reply to Thread
Results 1 to 11 of 11

Filtering a CSV with Active Directory Users and Groups

  1. #1
    Registered User
    Join Date
    10-06-2022
    Location
    Hamburg
    MS-Off Ver
    Office 365
    Posts
    8

    Question Filtering a CSV with Active Directory Users and Groups

    Hello,

    This is probably trivial for most people here, but I have a csv file from a script that reads out AD Users and their associated groups. The problem is that it spits it out in one long string in the first cell.
    Every line is a new user and it's hundreds of users, so not done manually. I've made a sample file that has the same structure. I want to be able to search for a group and see which users are associated with it. I've already wrote a Python script that reads it out and removes all the spaces en qoutation marks, but I've been stuck since then.

    Can someone here help me with this? Many thanks.

    SampleData.csv
    Last edited by Quiets; 10-20-2022 at 04:44 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,486

    Re: Filtering a CSV with Active Directory Users and Groups

    I'm seeing your data in separate rows with the fields combined in column A.

    If that is typical, you can use Text to Columns with comma and double quote as the delimiters. See the updated sample file (saved as .xlsx)
    Attached Files Attached Files
    Last edited by TMS; 10-06-2022 at 03:36 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-06-2022
    Location
    Hamburg
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Filtering a CSV with Active Directory Users and Groups

    Thank you, that already makes the data more clear. Do you happen to know how I would format it in such a way so that I can select a group and see which users are all within it?
    With my full data set not all users have the same identical amount of groups or types of groups, if that is something to consider. Many thanks.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,486

    Re: Filtering a CSV with Active Directory Users and Groups

    As you are using 365, you can use functions like UNIQUE and FILTER amongst others to present the data.

    Old school, you could perhaps use a Pivot Table.

    Please provide a more realistic and representative file to work with.

  5. #5
    Registered User
    Join Date
    10-06-2022
    Location
    Hamburg
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Filtering a CSV with Active Directory Users and Groups

    This is still a small file, but has the same structure and anonymized. Not every user has the same amount of groups.
    SampleTwo.csv

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,486

    Re: Filtering a CSV with Active Directory Users and Groups

    Are there any headings for this data?

    Not sure what you want to enter, where you want to enter it, and what you expect to see.

  7. #7
    Registered User
    Join Date
    10-06-2022
    Location
    Hamburg
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Filtering a CSV with Active Directory Users and Groups

    User1 would be "Username" header and all the other ones separated by a comma would be "Groups" since the list is an AD user and then which groups they're in.
    For example User1 is in groups "Domain Users","SG Team 6 3060" and "All Pos". I would like to be able to search for a group and get a list of all the user associated within it. Hopefully that is more clear.

  8. #8
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: Filtering a CSV with Active Directory Users and Groups

    Hi,
    It can be done with Power Query. Go to Data tab, Get & Transform group and choose "From text/CSV" option.
    Select your CSV file and click Open.
    In yhe new opened window select comma as a delimiter and than click Transform. The Power Query editor will be open. In PQ editor click split column, select "by delimiter" and choose comma as a delimiter. This will split your table in two columns.
    Select the second column, click split column, select "by delimiter", expand the Advanced and choose "by row".
    Right click on each table column and rename as you wish.
    After that you can choose from Close& Load menu the option "Close&Load To" and choose table. After loading you can filter the group as you wish.
    Attached Files Attached Files
    Diana Tanase


    If the solutions offered helped you to solve your problem, then mark the thread as SOLVED (thread tools in the top menu) and you can click on * to add reputation to those who helped you, as a way to say thank you !

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,486

    Re: Filtering a CSV with Active Directory Users and Groups

    I have been playing with this, on and off, for a few days. To be fair, mostly for my own education

    The attached workbook has grown, to some extent, and now has several sheets.

    Stage 0 - Instructions. Self explanatory
    Stage 1 - Where you input and split the raw data
    Stage 2 - Don't touch. It is automatic
    Stage 3 - Ditto
    Stage 4 - Is where you can select a group and list its users
    Stage 5 - A backup copy of the original test data

    Hope this works for you. Please don't ask how (some of) the formulae work
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    10-06-2022
    Location
    Hamburg
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Filtering a CSV with Active Directory Users and Groups

    Both your solutions seem perfect for me. Tomorrow at work I'll be able to test both solutions. I'll get back to you if I have any questions. Much thanks to both of you.

  11. #11
    Registered User
    Join Date
    10-06-2022
    Location
    Hamburg
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Filtering a CSV with Active Directory Users and Groups

    Quote Originally Posted by TMS View Post
    I have been playing with this, on and off, for a few days. To be fair, mostly for my own education

    The attached workbook has grown, to some extent, and now has several sheets.

    Stage 0 - Instructions. Self explanatory
    Stage 1 - Where you input and split the raw data
    Stage 2 - Don't touch. It is automatic
    Stage 3 - Ditto
    Stage 4 - Is where you can select a group and list its users
    Stage 5 - A backup copy of the original test data

    Hope this works for you. Please don't ask how (some of) the formulae work
    I've gotten an issue with your solution. When I open up the file and let it calculate for a bit. I get an error in stage 3 and 4. On both pages it says #NAME? with a triangle that says the formula contains an unsupported function. Am I missing something in Excel or? I haven't put any new data in yet. (For the other person, yes your solution also works to satisfaction, thansk!)

+ 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. Get list of Active Directory users in OU
    By I.T Delinquent in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2019, 11:32 AM
  2. Sort Active Directory users by group
    By denisuu in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 03-29-2019, 08:40 AM
  3. Replies: 0
    Last Post: 09-05-2013, 10:00 AM
  4. Replies: 0
    Last Post: 10-01-2012, 05:54 AM
  5. List Groups a User is a Member of - Active Directory
    By tomlancaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2011, 04:10 PM
  6. VBA List Groups a User is a Member of in Active Directory
    By tomlancaster in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2010, 04:41 AM
  7. How to show users in groups from report
    By malkaul in forum Excel General
    Replies: 12
    Last Post: 10-21-2009, 09:11 AM

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