Update to be better.
This commit is contained in:
parent
941fa17bbb
commit
bf090b40c5
@ -1,41 +1,78 @@
|
|||||||
## Connect to the Various MS365 Platforms
|
## Connect to the Various MS365 Platforms
|
||||||
$YourAdminAccount = 'dmcdowell@mpe.ca'
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
# Define the email address to be exported
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]
|
||||||
|
$ExportEmail,
|
||||||
|
# Set this flag if the mailbox is shared
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[switch]
|
||||||
|
$SharedMB
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
Import-Module ExchangeOnlineManagement
|
Import-Module ExchangeOnlineManagement
|
||||||
Connect-IPPSSession -UserPrincipalName $YourAdminAccount
|
Connect-IPPSSession
|
||||||
|
|
||||||
|
$user = get-aduser -Filter { mail -eq $ExportEmail }
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
|
$ExportName = $user.Name + ' Export'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ExportName = $ExportEmail + ' Export'
|
||||||
|
}
|
||||||
## Script Variables
|
## Script Variables
|
||||||
$AZCopyPath = '.\AD Scripts\Support\AZCopy.exe'
|
if ($SharedMB) {
|
||||||
$ExportName = "pocallaghan"
|
# add leading dot if shared mailbox
|
||||||
$ExportEmail = ".pocallaghan" #shared mailboxes need a leading dot.
|
$ExportEmail = ".$ExportEmail"
|
||||||
$DestinationPath = $Env:USERPROFILE + '\Downloads\'
|
}
|
||||||
|
|
||||||
New-ComplianceSearch $ExportName -ExchangeLocation $ExportEmail -AllowNotFoundExchangeLocationsEnabled $true | Start-ComplianceSearch
|
New-ComplianceSearch $ExportName -ExchangeLocation $ExportEmail -AllowNotFoundExchangeLocationsEnabled $true | Start-ComplianceSearch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$Status = Get-ComplianceSearch -Identity $ExportName
|
$Status = Get-ComplianceSearch -Identity $ExportName
|
||||||
Write-Output 'current status' $Status.status
|
$Progress = {
|
||||||
|
ID = 1
|
||||||
|
Activity = $Status.status
|
||||||
|
}
|
||||||
|
Write-Progress @Progress
|
||||||
Start-Sleep -Seconds 10
|
Start-Sleep -Seconds 10
|
||||||
} while ($Status.status -ne 'Completed')
|
} while ($Status.status -ne 'Completed')
|
||||||
|
|
||||||
|
$Progress = {
|
||||||
|
ID = 1
|
||||||
|
Activity = "Starting Export..."
|
||||||
|
}
|
||||||
|
Write-Progress @Progress
|
||||||
|
|
||||||
$Export_Action_name = New-ComplianceSearchAction $ExportName -Export -format FxStream
|
$Export_Action_name = New-ComplianceSearchAction $ExportName -Export -format FxStream
|
||||||
$Export_Action_name.name
|
$Export_Action_name.name
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$Export_Action = Get-ComplianceSearchAction -Identity $Export_Action_name.Name -IncludeCredential
|
$Export_Action = Get-ComplianceSearchAction -Identity $Export_Action_name.Name -IncludeCredential
|
||||||
|
|
||||||
|
$Progress = {
|
||||||
|
ID = 1
|
||||||
|
Activity = "Running Export"
|
||||||
|
}
|
||||||
|
Write-Progress @Progress
|
||||||
|
|
||||||
Start-Sleep -Seconds 10
|
Start-Sleep -Seconds 10
|
||||||
} until ($Export_Action.status -eq 'Completed')
|
} until ($Export_Action.status -eq 'Completed')
|
||||||
|
|
||||||
|
|
||||||
#Need to extract Container URI and SAS token from Results, and pass those to AZCopy EXE
|
#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(' ','')
|
#$ContainerURI = $export_action.results.split(';')[0].replace('Container url:','').replace(' ','')
|
||||||
$SASToken = $export_action.results.split(';')[2].replace(' SAS token: ','')
|
# $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 '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 'SAS Token: '
|
||||||
Write-Output $SASToken
|
# Write-Output $SASToken
|
||||||
#$FullURI = $ContainerURI + $SASToken
|
#$FullURI = $ContainerURI + $SASToken
|
||||||
#$AZArgs = " cp '$FullURI' --recursive '$DestinationPath'"
|
#$AZArgs = " cp '$FullURI' --recursive '$DestinationPath'"
|
||||||
#Start-Process $AZCopyPath $AZArgs
|
#Start-Process $AZCopyPath $AZArgs
|
||||||
|
Loading…
Reference in New Issue
Block a user