Skip to content

Instantly share code, notes, and snippets.

@thisboyiscrazy
Last active April 21, 2016 19:10
Show Gist options
  • Save thisboyiscrazy/6f708a576fa38948f4752279b7efcff9 to your computer and use it in GitHub Desktop.
Save thisboyiscrazy/6f708a576fa38948f4752279b7efcff9 to your computer and use it in GitHub Desktop.
Add first name + first letter of last name alias to all users in exchange
Get-Mailbox -resultsize unlimited |ForEach-Object {
$u = $_ | Get-User
if ($u.Lastname.length -gt 1 -and $u.FirstName.length -gt 0) {
$new = (($u.FirstName) + ($u.LastName.Substring(0,1))).tolower() + "@example.com"
Set-Mailbox $_.id -EmailAddress @{add=$new}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment