Active Directory Response Time

Measure the response time for a user lookup on each DC within a domain.

— Binary Adventures

If you ever wondered how long it takes each domain controller in your domain to perform a user lookup, here’s a relatively small and simple script that does just that.

Given a domain name (e.g. acme.site) and user account (e.g. wile.e.coyote), the script will retrieve all domain controllers within that domain, and use Get-ADUser to retrieve the user object. The time it takes to perform the lookup is captured (using Measure-Command, with millisecond precision) as well as whether or not the action was successful.

Results are stored in an array of PSCustomObject, each containing the DC hostname, a boolean indicating success or failure, and a TimeSpan object with the elapsed time. If you pass the results on to the Format-Results function, the data will be send to stdout, indicating success or failure by colouring the duration green or red.

Example:

ssesvgkm1191.acme.site......[00:00:00.0412119]
IIFIKWHT1101.acme.site......[00:00:00.0462304]
IIFIKWHT1171.acme.site......[00:00:00.0685567]
IIFIKWHT1161.acme.site......[00:00:00.0768323]
IIFIKWHT1110.acme.site......[00:00:00.1871499]
ssesvgkm1117.acme.site......[00:00:00.1922456]
ssesvgkm1119.acme.site......[00:00:00.1952457]
RFYIKWHT1117.acme.site......[00:00:00.1962261]
RFYIKWHT1119.acme.site......[00:00:00.2055862]
WPCIHWHT1116.acme.site......[00:00:00.2077982]
IITINGHT117.acme.site.......[00:00:00.2783724]
IITIKWRHTS119.acme.site.....[00:00:00.3024234]

Code

Reference