We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script Repository

Get mailbox move status in Exchange Online

May 08, 2023 Views: 3557

The script gets the status of the move of a user's mailbox in Exchange Online. The status is added to the Execution Log of the operation.

Edit Remove
PowerShell
try
{
    # Get the object ID in Microsoft 365
    $objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
    return # The user doesn't have a Microsoft 365 account
}

# Connect to Exchange Online
$Context.CloudServices.ConnectExchangeOnline()

try
{
    $moveRequest = Get-MoveRequest -Identity $objectId.ToString() -ErrorAction Stop
}
catch
{
    return # There are no requests to move the user's mailbox
}

# Output Move request status
$Context.LogMessage("Move request status: " + $moveRequest.Status, "Information")

Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers