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
and tried New-MailboxExportRequest
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
Also 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 ?
PS:
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 ?
Best Answer
You can't export Exchange Online mailbox directly to PST via PowerShell with built-in tools. Required New-MailboxExportRequest doesn't exist Online (or is not exposed to us mortals).
You can:
I'm as frustrated as you are. Exporting mailboxes for departing users for long-term storage is needlessly annoying. If we could just export to Azure Blob just as with import, it'd be a good start.