Skip to content

Instantly share code, notes, and snippets.

@devynspencer
Created November 26, 2019 20:35
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 devynspencer/27df168d44866c36d3fd1af879013ac4 to your computer and use it in GitHub Desktop.
Save devynspencer/27df168d44866c36d3fd1af879013ac4 to your computer and use it in GitHub Desktop.
# Given a list of users and computer names, add the SAM account name to each
@{
Users = @(
@{
Name = "Joe Joesworthy"
ComputerName = "P9XYZ123"
}
@{
Name = "Seandog Millionaire"
ComputerName = "MJXYZ123"
}
)
}
$Users | select *, @{n="SamAccountName";e={$Name = $_.Name; (Get-ADUser -Filter { ANR -eq $Name }).SamAccountName.ToLower()}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment