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
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?
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