
Explanation/Reference:
Explanation:
$mailboxes = Get-Mailbox: This will retrieve a list of all mailboxes and store it in the $mailboxes variable.
$newaddress = $mailbox.alias + "@contoso.com" : This will take each mailbox's alias and append
@contoso.com to it. For example: an alias of Jane.Thomas will become
[email protected] .
This is therefore creating a new email address for each user (mailbox) and storing it in the $newaddress variable.
$mailbox.EmailAddresses += $newaddress : This adds the new (@contoso.com) email address to any existing email addresses and stores the new value in the $mailbox.EmailAddresses variable.
Set-Mailbox -Identity $mailbox.alias -EmailAddresses $mailbox.EmailAddresses : This cmdlet sets the email addresses in the $mailbox.EmailAddresses variable to be the email addresses for each mailbox based on the mailbox's alias.