
The macros will not work with the top two options that disable all macros or unsigned macros.

If objDictionary.Exists(strKey) = True Thenįirst: You need to have macro security set to the lowest setting, Enable all macros during testing. StrKey = objItem.Subject & "," & objItem.Body & "," & objItem.SentOn If InStr(1, objItem.MessageClass) "IPM.Schedule" Then Set objDupFolder = ("Duplicates")įor i = To 1 Step -1 Set objDictionary = CreateObject("scripting.dictionary") After reviewing the duplicates, delete the folder. The macro will create a subfolder named Duplicates and move the duplicate messages to it. To use, select a folder that needs checked for duplicates and run the macro. See Duplicate Remover Tools for third party utilties. If you have a lot of messages in the folder, expect it to take some time to run. While((Get-ComplianceSearchAction $Name2).This macro is slow. New-ComplianceSearchAction -SearchName $Name -Purge -PurgeType HardDelete -Confirm:$False | Out-Null Press Enter to hard delete the email or Ctrl+C to exit” Read-Host “Please verify the search results above. If($AlreadyImportedModules.Name -notcontains $i) #Importing modules if not already imported Please make sure that you have at least ‘Compliance Search’ and ‘Search And Purge’ roles assigned in Security & Compliance Center.Ī maximum of 10 items per mailbox can be removed at one time.” -ForegroundColor Yellow Write-Host “The script finds and deletes unwanted such as a malicious email from user mailboxes. #Please note that the script has been provided As Is. Please do share your feedback and suggestions. If you want to soft delete the emails, you need to change -PurgeType parameter to SoftDelete.

Please note that the script hard deletes the emails. It helps in a scenario wherein you want to delete e.g. It tries to combine all steps at one place. The script is based on Microsoft article.
