– Open Windows PowerShell as Admin
– Connect to Security & Compliance Center PowerShell
$credentials = get-credential;
Connect-ExchangeOnline -Credential $credentials
$SccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credentials -Authentication “Basic” -AllowRedirection;
Import-PSSession $SccSession
Or Go to https://docs.microsoft.com/en-us/powershell/exchange/connect-to-scc-powershell?view=exchange-ps for more information
– Soft-delete messages
New-ComplianceSearchAction -SearchName “NameOfTheSearch” -Purge -PurgeType SoftDelete
– Hard-delete messages
New-ComplianceSearchAction -SearchName “NameOfTheSearch” -Purge -PurgeType HardDelete
– Then to see progress of the action you can run
Get-ComplianceSearchAction
– Or specifically you can get progress of search name
Get-ComplianceSearchAction ‘NameOfTheSearch_Purge’ | Select *