Speeding Up AD Object Retrieval

Recently, I was asked if I could take a list of roughly 4,000 users and query AD for specific attributes. I figured it was no big deal, Get-QADUser would easily take care of the task. However, as my query ran, I could see that each query was taking several seconds.

measure-command {get-qaduser langeda}

TotalSeconds      : 4.3829259

4.38 seconds * 4,000 queries is 17,520 seconds, or 4.87 hours. Clearly this was not going to be acceptable!

I remember previously reading a post discussing precisely this problem. A quick search through my RSS feeds turned up this post by Dmitry Sotnikov, Fastest was to retrieve AD objects (http://dmitrysotnikov.wordpress.com/2009/09/10/fastest-way-to-retrieve-ad-objects/). The key to speeding up the queries, it turns out, is to use the –DontUseDefaultIncludedProperties parameter.

measure-command {get-qaduser langeda -dontusedefaultincludedproperties}


TotalSeconds      : 1.6801555

A significant improvement! He also recommends optimizing the search with specific parameters. For example,

Get-QADUser -SamAccountName langeda

should return a result quicker than

Get-QADUser langeda

There’s a lot of great information over on Dmitry’s blog, and I highly recommend adding him to your RSS feed.

~Daniel

Advertisements

5 thoughts on “Speeding Up AD Object Retrieval

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 )

Google+ photo

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

Connecting to %s