What is the best way to tell if a mailbox has been succesfully provisioned in Office365?

David Jenkins 946 Reputation points
2020-08-24T14:11:32.087+00:00

I'm trying to automate a script. I'm using some automation software that licenses the user. I am having an issue because I'm trying to automate the creation of remote mailboxes in a hybrid environment.

In the automation software I can use powershell. I can login to Exchange Online and so on. The issue is that there is a delay in the creation and the ability to modify the mailbox.

Is there any way to ensure a new account is completely provisioned?

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,569 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Andy David - MVP 149.1K Reputation points MVP
    2020-08-24T15:03:59.423+00:00

    If you are using AADConnect to sync from on-prem to ExO, thats expected. It can take up to 30 minutes to sync unless you do a manual delta sync.

    If you want to simply make sure the mailbox exists in 365, get-mailbox <user> will return that object when connecting to Exchange Online via Powershell.

    Unless you are thinking you need to check something else to verify the license.

    If so, then:

    Get-MsolUser -UserPrincipalName <user account UPN> | Format-List DisplayName,Licenses
    Get-MsolUser -UserPrincipalName <user account UPN> | Format-List DisplayName,Licenses

    https://learn.microsoft.com/en-us/microsoft-365/enterprise/view-account-license-and-service-details-with-microsoft-365-powershell?view=o365-worldwide


  2. Andy David - MVP 149.1K Reputation points MVP
    2020-08-24T16:33:32.903+00:00

    You really need to look at both the Azure and EXo accounts if you want to be thorough :)

    One easy way to tell is if the ProxyAddresses on the Msol side match the Email Addresses on the ExO side.

    All the Azure ProxyAddresses should be contained in the mailbox. ( not the other way around)
    If that is the case, you know its synced up.

    You could also look at modified times on each object, but they wont not typically match as their a delay sometimes.

    I dont put a lot of weight on OverallProvisioningStatus. I have seen that not show "success" many times on accounts that are just fine.

    P.S. I should add that if the mailbox exists in Exchange Online, that's typically all that is needed and you should be able to modify. At times, there is a delay or issues between the AzureAD and Exchange Online sync, but, for the most part, if the mailbox exists in ExO, you are good to go and any modifications you make will be reflected at some point if there is an issue.

    0 comments No comments

  3. KyleXu-MSFT 26,266 Reputation points
    2020-08-25T05:26:15.147+00:00

    As far As I know, you could assign license to mailbox directly when this account show in Azure AD. So, you can check whether the account appears successfully, then assign license to it(You can also create loop which check every 1 minute):

    $data = Get-MsolUser -UserPrincipalName User1@domain.com -erroraction 'silentlycontinue'  
    if ($data -ne $null){  
    [Assign license Action][1]  
    }  
    else{  
    write-host "Try again later"  
    }  
    

    About other action, due to remote mailbox's AD account is hosted on local AD, so you need to modify it from local AD rather than Azure AD. You can modify local account at any time, regardless of whether the account is synchronized, because the modify action will synchronized later.


    If the response is helpful, please click "Accept Answer" and upvote it.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.