Skip to content

Instantly share code, notes, and snippets.

@matthewbodaly
Created March 15, 2019 04:28
Show Gist options
  • Save matthewbodaly/56e62919f1b1829db686b1050f35b793 to your computer and use it in GitHub Desktop.
Save matthewbodaly/56e62919f1b1829db686b1050f35b793 to your computer and use it in GitHub Desktop.
Thanks StackOverflow
# your funeral
# This isn't original to me
# https://stackoverflow.com/questions/47035953/how-to-get-samaccountname-from-an-e-mail-using-powershell
Get-Content ".\in.txt" |
ForEach-Object { Get-ADUser -LDAPFilter "(mail=$_)" } |
Select-Object -ExpandProperty sAMAccountName |
Out-File ".\out.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment