Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
eDiscovery automation
# Import Microsoft Graph and Connect
Install-Module Microsoft.Graph
Select-MgProfile -Name "beta"
Import-Module Microsoft.Graph
Connect-MgGraph -Scopes "Policy.Read.All","eDiscovery.ReadWrite.All","Application.Read.All"
$casename = "Test-Compliance-Export"
$custodianemail = "someaccount@contoso.com"
$collectionname = $casename+" Collection"
$reviewsetname = $casename+" Review Set"
$reviewsetqueryname = $casename+" Review Set Query"
$case = New-MgComplianceEdiscoveryCase -DisplayName $casename
$custodian = New-MgComplianceEdiscoveryCaseCustodian -CaseId $case.Id -Email $custodianemail
$custodianuser = New-MgComplianceEdiscoveryCaseCustodianUserSource -CaseId $case.Id -CustodianId $custodian.Id -Email $custodianemail -IncludedSources "mailbox,site"
$reviewset = New-MgComplianceEdiscoveryCaseReviewSet -CaseId $case.Id -DisplayName $reviewsetname
$collection = New-MgComplianceEdiscoveryCaseSourceCollection -CaseId $case.Id -DisplayName $collectionname -DataSourceScopes "allCaseCustodians" #-AddToReviewSetOperation $reviewsetname <-commented out because error is switch isn't valid
#$reviewsetquery = New-MgComplianceEdiscoveryCaseReviewSetQuery -CaseId $case.Id -ReviewSetId $reviewset.Id -DisplayName $reviewsetqueryname -Query
#Export-MgComplianceEdiscoveryCaseReviewSet -caseid $case.id -reviewsetid $reviewset.Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment