We have a exchange hybrid environment. (some users are in onpremises exchange and some users are office 365. )
When we want to export emails from onpremis we use , below command to export mail box and archive.
New-MailboxExportRequest -Mailbox "user" -FilePath \\mysrv\l$\PST\Mailbox-user.pst; New-MailboxExportRequest -Mailbox "user" -IsArchive -FilePath \\mysrv\l$\PST\Mailbox-user-archive.pst -confirm:$false
New-MailboxExportRequest works fine for onpremis users not for office 365. is there a way to export office 365 user mail box to pst using powershell ?
What i have tried so far:
I logged to office 365
$UserCredential = Get-Credential Import-Module MSOnline Connect-MsolService -Credential $UserCredential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session
But it generates an error. apparently office 365 dont know that command
PS C:\Users\pp> New-MailboxExportRequest New-MailboxExportRequest : The term 'New-MailboxExportRequest' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + New-MailboxExportRequest + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (New-MailboxExportRequest:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Get-Command *Export* results are as follows
Tried googling, yet could not find a viable option. can some one guide me please ? What is the compatible command in office environment to do this ?
I have tried
https://www.codetwo.com/admins-blog/how-to-export-office-365-mailboxes-to-pst-using-ediscovery/ with E5 license and it works in the GUI perfectly. but my concern is even with e-discovery, and having license any possibility to do it with powershell ? i mean to script/automate via powershell ?