Skip to content

Instantly share code, notes, and snippets.

@arjancornelissen
Created July 23, 2019 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arjancornelissen/bf6292aff81281af1423bb95ecdca70f to your computer and use it in GitHub Desktop.
Save arjancornelissen/bf6292aff81281af1423bb95ecdca70f to your computer and use it in GitHub Desktop.
Where-Object on large datasets
$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
foreach($user in $users)
{
$msoluser = $msolusers | where-object {$_.ObjectID -eq $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