## Connect to the Various MS365 Platforms $YourAdminAccount = 'dmcdowell@mpe.ca' Import-Module ExchangeOnlineManagement Connect-IPPSSession -UserPrincipalName $YourAdminAccount ## Script Variables $AZCopyPath = '.\AD Scripts\Support\AZCopy.exe' $ExportName = "pocallaghan" $ExportEmail = ".pocallaghan" #shared mailboxes need a leading dot. $DestinationPath = $Env:USERPROFILE + '\Downloads\' New-ComplianceSearch $ExportName -ExchangeLocation $ExportEmail -AllowNotFoundExchangeLocationsEnabled $true | Start-ComplianceSearch do { $Status = Get-ComplianceSearch -Identity $ExportName Write-Output 'current status' $Status.status Start-Sleep -Seconds 10 } while ($Status.status -ne 'Completed') $Export_Action_name = New-ComplianceSearchAction $ExportName -Export -format FxStream $Export_Action_name.name do { $Export_Action = Get-ComplianceSearchAction -Identity $Export_Action_name.Name -IncludeCredential Start-Sleep -Seconds 10 } until ($Export_Action.status -eq 'Completed') #Need to extract Container URI and SAS token from Results, and pass those to AZCopy EXE #$ContainerURI = $export_action.results.split(';')[0].replace('Container url:','').replace(' ','') $SASToken = $export_action.results.split(';')[2].replace(' SAS token: ','') Write-Output 'Process Complete: Use the SAS Token Below in the "Export" Tab of the following URL: https://compliance.microsoft.com/contentsearch' Write-Output 'SAS Token: ' Write-Output $SASToken #$FullURI = $ContainerURI + $SASToken #$AZArgs = " cp '$FullURI' --recursive '$DestinationPath'" #Start-Process $AZCopyPath $AZArgs #> Disconnect-ExchangeOnline