Skip to content

Instantly share code, notes, and snippets.

@arieljannai
Last active June 8, 2016 05:53
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 arieljannai/2d10ef5f6077c4b8828aa129480822e1 to your computer and use it in GitHub Desktop.
Save arieljannai/2d10ef5f6077c4b8828aa129480822e1 to your computer and use it in GitHub Desktop.
Find users where their email does not match their usernames
# Unmatch
Get-ADUser -filter * -Properties SamAccountName, DisplayName, EmailAddress | select SamAccountName, DisplayName, EmailAddress | Where-Object {-not ($_.EmailAddress -like $_.SamAccountName + 'REPLACE_WITH_@COMPANY.COM')}
# Match
Get-ADUser -filter * -Properties SamAccountName, DisplayName, EmailAddress | select SamAccountName, DisplayName, EmailAddress | Where-Object {$_.EmailAddress -like $_.SamAccountName + 'REPLACE_WITH_@COMPANY.COM'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment