Find group members by location

Today I had to promote a local event to everyone on our cloud taskforce. The distribution list we have for everyone interested in cloud projects is quite large so I thought I would share this one-liner with you.

The first version I tried was quite straight-forward – simply get all team members and filter out the members based on their city:

Get-QADGroupMember Cloud -Indirect |
    where { $_.City-eq "Aliso Viejo" }

However, this actually was quite slow – because the group is big and all the filtering was happening on the client side (all objects were extracted from domain controller and then filtered by PowerShell on my workstation). The solution is to use parameters of the initial Get cmdlet. Get-QADGroupMember unfortunately does not have the City parameter yet, so I used the universal LdapFilter parameter to do the proper filtering.

Get-QADGroupMember Cloud -Indirect -LdapFilter '(l=Aliso Viejo)'

This second one-liner performed almost twice faster – so this is the one I would recommend for large group use!

Dmitry

Advertisement

2 Responses to “Find group members by location”


  1. 1 Andy Tillo (@tillo13) October 28, 2011 at 5:35 pm

    can this also be applied to add-qadgroupmember? I have a query that pulls 15,000 users from a get-qadgroupmember, and it takes 4 hours to upload them back to the other group (tried using the 15,000 as variable and as a text file downloaded – the process just takes forever. Do you have any ideas on how to speed up the population of the group?

    • 2 Dmitry Sotnikov October 28, 2011 at 6:13 pm

      Andy,

      Add-QADGroupMember unfortunately does not have these extra parameters. You can probably try to optimize get-qadgroupmember by specifying -DontUseDefaultIncludedProperties parameter when making the query.

      Also, are you trying to clone membership entirely or do you actually need to filter by attributes (like City in the example above). If you are just replicating the who thing as is – you might be better off just copying the Members attribute.

      Dmitry


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




My Recent Tweets

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

December 2010
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

%d bloggers like this: