Skip to content

Instantly share code, notes, and snippets.

@stromvirvel
Created November 12, 2019 07:36
Show Gist options
  • Save stromvirvel/02cc7ba80a24281f02557a478368bcfa to your computer and use it in GitHub Desktop.
Save stromvirvel/02cc7ba80a24281f02557a478368bcfa to your computer and use it in GitHub Desktop.
# Get users with same username part of UPN
$users = get-azureaduser -all:$true
foreach($user in $users)
{
# do we have more users with the same username-part of the UPN?
$username = $user.userprincipalname.split("@")[0]
if ( ($users | ? {$_.userprincipalname -like "$($username)@*"} | Measure-Object).count -gt 1)
{
write-output "$($user.userprincipalname)`t$($user.mailnickname)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment