Forum Discussion
PS array performance >40K entries
- Nov 10, 2020
Joe_Cauffiel Thanks for the alternative solution. My next step was to switch over to using a HASH array but it still does not explain why .contains is taking 2ms and .where is taking 1000ms when they are both using the same search criteria and scanning through the array. I'm wondering if I am missing an option on the ".where" somehow.
The Contain method will return true or false, but to use it in your case, I guess you will need to add
$AllADUsers.UserPrincipalName.Contains($SearchID)
I guess this is related to how many items in the object, so in your case, each object of the array contain multiple items. not a
Key= Value
if you check the Where{} statement, you are going to each item properties, and this is why you get the result.
The $AllADUsers.Contains("*user1@necad.ae*") is not equal to $AllADUsers.Where({$_.UserPrincipalName -eq "$SearchID"})
farismalaeb Hi
The contain statement only takes 2ms
The where statement takes 1000ms
The search string is the same in both cases. So changing the contains statement won't address my issue with the where method.