Azure AD Connect > Managing with Powershell

Copper Contributor

Hi Guys,

 

1. We currently run Azure AD Connect with our 2011 server to Sync with Office 365.

 

I have a shared mailbox that somehow has the default Microsoft email address as the primary email address.

 

I have tried many powershelgl commands but I cant seem to correct it.

 

Can someone please recommend the MSonline module command to set the primary email address on a shared mailbox

 

Primary is currently: helpdesk@mycompany.onmicrosoft.com > should be helpdesk@mycompany.com

 

Many Thanks

7 Replies

I guess you have to use Exchange online cmdlets

 

How to connect to Exchange online:

https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx

 

change mailbox address:

http://www.remylarrieu.com/en/office-365-change-a-shared-mailbox-email-address/

Thanks for the reply.

 

I don't think the Powershell for AD connect uses that cmdlet:

 

I am using the following:

  1. Import-Module MsOnline
  2. Enter Connect-MsolService -Credential $credential

I tried Set-Mailbox -Identity oldEmail@domain.com -EmailAddresses newEmail@domain.com

 

It does not recognise the command Set-Mailbox.

 

Any ideas

 

Thanks

it's because MsOnline powershell module does not contain Set-Mailbox cmdlet.

 

To view all the available cmdlets that are available in MsOnline module you can enter in powershell

get-command -Module msonline

Yes you are correct, and I can not see a command to change the primary email on a shared mailbox

 

I can use Set-MsolUserPrincipalName but it only changes the value on a user not a shared mailbox

 

Can I use the Exchange cmdlet to connect to Office 365 and use other commands?

 

Thanks

Hello,

 

Even using the Exchange Powershell I get an error but it is being synced with Azure AD Connect (formerly Azure AD Sync)

 

I have attached a screenshot of the error.

 

Thanks

Well I can see that you have Exchange on-premises. What primary SMTP address is set in Exchange? Are you able to change email address via ECP?

As from error message it says that you have to change this internaly, afterwards changes should be synced to cloud

We don't use an onsite exchange server any more.

 

I [solved] it by doing the following:

 

** - REMOVE USERS: (caution back up .pst offline emails first)

 

1. Move the AD user on your local server into a No sync folder

2. Sync the AD with Start-ADSyncSyncCycle -PolicyType Delta

3. This will put the AD user on Office 365 into the recycling bin.
4. Get-MsolUser -ReturnDeletedUsers

 

Then permanantly delete the user:


5. Remove-MsolUser –UserPrincipalName user@mycompany.com -RemoveFromRecycleBin

6. Move the AD user back into the SYNC folder and force a sync

 

** - FORCE SYNC NOW

 

7. Start-ADSyncSyncCycle -PolicyType Delta

8. Check the Office 365 Portal > Done.

 

Thanks for your assistance.