Forum Discussion
Export to PST via Powershell
- Aug 10, 2017
No way to do it without going to the SCC and initializing the download via the click-one app, sorry. Perhaps you can automate it via AzCopy or some other tool that takes container/token as input - you can get those via the Result property of Get-ComplianceSearchAction.
As for the cmdlet, make sure you also use the -Format parameter!
The Format parameter specifies the format of the search results when you use the Export switch. Valid values are:
FxStream Export to PST files. This is the only option that's available when you export search results from the Security & Compliance Center.
Mime Export to .eml messsage files. This the default value when you use cmdlets to export the search results.It's most likely what causes the issue in your case.
Once you get the SAS Token and URL from the export using commands discussed in forum. Ensure you have the download tool installed on the machine you are running the code and then It can be done programmatically using PowerShell-
$arguments = "-name ""$exportname""","-source ""$containerURL""","-key ""$sastoken""","-dest ""$exportLocation""","-trace true"
Start-Process -FilePath "$exportExe" -ArgumentList $arguments -wait
You can either use -wait switch to let the script wait until download is completed or you can keep querying the status of the process every minute or so.