Created
September 30, 2015 01:56
-
-
Save Windos/225c1855922c7471d839 to your computer and use it in GitHub Desktop.
It turns out there are a few different ways to search for a given SamAccountName ($user) using the Get-ADUser cmdlet. As part of a bigger project, I decided to find out which method was faster.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Speeds are measured in milliseconds and are the average over 256 test runs | |
# 6.3 ms | |
Get-ADUser -Filter { SamAccountName -eq $user } | |
# 6.7 ms | |
Get-AdUser -LDAPFilter "(SamAccountName=$user)" | |
# 8.5 ms | |
Get-ADUser -Identity $user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment