How can I fix my script for purging emails?

0
7
Asked By TechieTurtle23 On

I'm encountering issues with a script intended to purge specific emails, particularly phishing ones, from our system. I suspect it might be failing due to our Tenant not being set up for Microsoft Purview, which isn't an expense we can manage right now.

I've tried using the script directly, but it didn't yield any results. The script prompts like 'Search Name to be Created?' and 'Sender Address?' didn't trigger as expected. Afterward, I attempted to modify the script to test it with some emails I had prepared, but still no success.

There were no error messages—everything just seems to run without actually doing anything. I've executed it both in the ISE and the Exchange Management Shell, ensuring I'm running them with admin privileges and that I'm correctly connected to the environment.

We previously managed to purge emails using the Message Trace feature in the Exchange Admin Center, but that option seems to be unavailable now. We're operating in a hybrid environment and the service account I'm using has Exchange Administrator privileges, which I prefer to keep disabled until needed.

Is there a way to make this script work, or are there alternative methods? I'm also exploring a two-part script that involves using an App Password for a service account, but it's not functioning as intended either. Any insights would be greatly appreciated!

3 Answers

Answered By ScriptSavvy12 On

The API for Purview changed last year, so that script you have likely won’t work anymore. Even when it did, it could only delete 10 emails at a time unless you put it in a loop. A better approach might be using Microsoft Graph to search through each mailbox and delete the emails you want.

Answered By EmailGuru88 On

To run that script successfully, you’ll need the eDiscovery Manager or Admin role in Microsoft Purview. Without those permissions, the script won't work as intended.

Answered By CodeCritic007 On

Honestly, you've not shared much about what you've tried or what went wrong. If there are no errors but it's still not working, have you considered running the script line by line to identify where it fails? That might provide you with some clues on what to fix.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.