Can Someone help check the scripts running in the https://compliance.microsoftonline.cn/contentsearchv2 in O365
Can Someone help check the scripts?
We are using the Office 365 in Chian and in the Compliance center there we can run the tasks to use content Search function to export user emails see the links https://compliance.microsoftonline.cn/contentsearchv2
and we have search scripts and then the Search jobs will be beginning automatically. BUT now the search shows NOT started and we need to click into by hand to rerun.
the scripts as below please someone can helps thanks for the times and helps.
Create log function
Function LogWrite
{
Param ([string]$logstring)
Add-content $Logfile -value $logstring
}
#===========================================================
$workingDir = Convert-Path .
$LogDate = get-date -f yyyyMMdd
$Logfile = "$workingDir\Logfile3_$LogDate.log"
$inputSource = Import-CSV "$workingDir\in-place_ediscovery_search_list.csv"
ForEach ($info in $inputSource )
{
$infoData = $info.Name
$infoData2 = $info.Sourcemailboxes
$infoData3 = $info.startdate
$infoData4 = $info.enddate
$error.Clear()
#To enable LitigationHold
Set-Mailbox -Identity $infodata2 -LitigationHoldEnabled $true
#To perform mailbox search in existing eDiscovery case --- please update the case name based on the real operations
New-ComplianceSearch -case "CN leaver hold" -Name "$infoData" -ExchangeLocation $infoData2 -ContentMatchQuery "date:$infoData3..$infodata4"
sleep 5
Get-ComplianceSearch -case "CN leaver hold" | where{$_.status -eq "NotStarted"} | Start-ComplianceSearch
if($error.Count -gt 0)
{
$error | %{
$LogDate2 = get-date -f "yyyy-MM-dd HH:mm"
$errorLogMSG = $_
LogWrite "($LogDate2) Error : $errorLogMSG "
}
}
}