Thursday, December 31, 2015

Optimising AD query results.


Limiting results to queries on the active directory (AD) is often important because the results can often be relatively large sets of data and you may only need examples of the type of objects you are querying.  Restricting results to the first 10 is often useful.

| Select -first 10

The querying method can also be optimised by correctly using filter and where conditions.

In a nutshell this paragraph from the post on the link below explains why.

"The –Filter and –LdapFilter parameters cause filtering to take place on the remote computer, thus reducing the amount of information that gets returned across the network to your computer. By contrast, Where-Object causes filtering to take place on your computer, which means that all the information about all your users must be returned to your machine."


http://blogs.technet.com/b/csps/archive/2010/06/06/reffilterwhere.aspx