Last active
July 23, 2019 20:15
-
-
Save arjancornelissen/a832d587a2363949f45c33eef40d1480 to your computer and use it in GitHub Desktop.
Enhanced where-object on large datalist
This file contains hidden or 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
$msolusers = Get-MsolUser -All | Select-object ObjectId, WhenCreated, LastPasswordChangeTimestamp, @{n="mfaenabled";e={$_.StrongAuthenticationMethods.Count -gt 0}} | |
$users = Get-AzureADUser -All $true | Select-Object ObjectId, UserPrincipalName, DisplayName, @{n="onpremDN";e={$_.ExtensionProperty.onPremisesDistinguishedName}}, CompanyName, AccountEnabled, UserType | |
# Create empty array and do a foreach on every item, this takes a few seconds on 30.000 items | |
$msoluserArray = @{} | |
$i=0 | |
$msolusers.foreach({ | |
$msoluserArray["$($psitem.ObjectId)"] = $i | |
$i++ | |
}) | |
foreach($user in $users) | |
{ | |
$msoluser = $msolusers[($msoluserArray[$user.ObjectId])] | |
# do something with this data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment