Last active
April 21, 2016 19:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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