Not able to set LitigationHoldEnabled as true

I am trying to set true to LitigationHoldEnabled and getting following error. I am using following code. Please advise what wrong I doing

============Code

Import-Csv  "D:\pscript\users.csv" | foreach {
        $Mailbox = Get-Mailbox -Identity $_.userPrincipalName -ErrorAction SilentlyContinue
        If ($Mailbox) {
            Write-Host $_.userPrincipalName "Mailbox exists"
        } 
        Else { 
            Write-Host $_.userPrincipalName "Mailbox does not exists"
            New-MoveRequest -Identity $_.userPrincipalName -Remote -RemoteHostName webmail2.myconnect.net -TargetDeliveryDomain mycon.mail.onmicrosoft.com -RemoteCredential $msol -BadItemLimit 50 -LargeItemLimit 50 -AcceptLargeDataLoss -warningaction "SilentlyContinue"

            Write-Host $_.userPrincipalName "Mailbox Migration is started"
            
            #Settingup Litigation & Hold
            Set-Mailbox -Identity $_.userPrincipalName -LitigationHoldEnabled $true
    
                Write-Host "------------------------------------------------------------------------------"
                Start-Sleep 60
        }

}

============Error

WARNING: If you want to change LitigationHoldEnabled and LitigationHoldDuration on an inactive mailbox, please add the
InactiveMailbox switch.
The operation couldn't be performed because object *** Email address is removed for privacy ***' couldn't be found on
'domain.PROD.OUTLOOK.COM'.
    + CategoryInfo          : NotSpecified: (:) [Set-Mailbox], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : [Server=asdasdROM,RequestId=187adsd1a1f6-1060-407a-888d-f6basdasd6c28a8,TimeStamp=31/08/201
   6 5:24:46 PM] [FailureCategory=Cmdlet-ManagementObjectNotFoundException] 7858EA80,Microsoft.Exchange.Management.Re
  cipientTasks.SetMailbox
    + PSComputerName        : outlook.office365.com

 

Question Info


Last updated May 30, 2018 Views 281 Applies to:
Answer
Answer

Hi Avian2,

 

As this forum mainly focuses on Office 365 for Business online services, please contact the PowerShell Script Forum for professional support on the error you have encountered.

 

Here is the link: https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?category=scripting&forum=dpmpowershell,ITCG,scriptexplorer&sort=relevancedesc&brandIgnore=True&searchTerm=office+365

 

We appreciate your kind understanding and patience.

 

Best Regards,

Ruel

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.