Scenario: Your company uses a sign in domain however some users need to be able to send from a different email as their primary email address.
Example:
The Office 365 graphical user interface does not currently give you the ability to change this setting.
So you need to be able to get dirty with PowerShell and here are the steps.
Prerequisites:
Download and install Microsoft Online Services Module for Windows PowerShell
Stage 1 – Setting Up PowerShell to receive the commands
- Run the PowerShell module as administrator.
Type:
Set-ExecutionPolicy -ExecutionPolicy unrestricted
and press EnterType:
$LiveCred = Get-Credential
and press EnterYou will be prompted to log in. Use your Office365 administrative account.
Type:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection
and press Enter.Type:
Import-PSSession $Session
and press Enter.
Stage 2 – Getting the email addresses and changing the primary
Stage 2 – Getting the email addresses and changing the primary
-
Type:
$Mailbox = Get-Mailbox –Identity Jeff
and press Enter. Where Jeff is the part of the login email address in front of the @ sign (ie.)
-
Type:
ForEach ($i in $Mailbox.EmailAddresses) {Write-Host $i -NoNewline "`b, "}
and press enter.Note:
You now have all of the information required to change the primary email address. You need to use the output of the previous command to build you next command. We will start by adding something to the front of the output and then remove a comma from the end. Finally we will change capitalization of SMTP within the output to specify which email address is the primary.
I suggest you copy the output to notepad, make the edits and then copy the final command back. -
Add to the front of the output from line 2 type:
Set-Mailbox Jeff –EmailAddresses
Note: Jeff is the login name before the @ sign in the email address. This will change based on your account information. Ensure there is a space between the text you just added and the start of the output from step 2.
-
Now go to the end of the output from step 2 and remove the trailing comma.
-
Now find the email address you want to make the primary email address within the output from step 2 and capitalize SMTP just before it. You will also need to change the old primary SMTP to miniscule letters smtp.
-
Copy the command back into PowerShell and press Enter.
Note: if you need to change more than one email address just repeat the steps in Stage 2.
-
Once you have finished modifying the primary email addresses you shall issue the following command:
Remove-PSSession $Session
and press Enter
Stage 3 – Testing the email addresses
Stage 3 – Testing the email addresses
Ensure the users test the email addresses by sending them to a non-office365 email address that you can verify such as Hotmail.
Jeff Loucks
Chief Strategy Officer | Winrox | 425-577-7377