Answer a subject rights request with Microsoft Purview eDiscovery.
Someone has asked to see the personal information you hold about them, or you have decided to delete it. This guide shows how to find it across Exchange, Teams, OneDrive and SharePoint with Microsoft Purview eDiscovery. You then review and redact it, export a copy for the reply, and delete it where you have decided to.
It is written for the privacy officer or Microsoft 365 administrator who runs the request, and it gives the roles, conditions, cmdlets and Graph calls each step needs. Most steps have a screenshot from a demo tenant.
Version 2.2
What the Privacy Act asks for, and what it does not.
- Access · APP 12
- Give an individual access to the personal information you hold about them, in the way they ask where that is reasonable and practicable. An agency cannot charge for access. An organisation cannot charge for the request, and any charge for giving access must not be excessive. 1
- Correction · APP 13
- Take reasonable steps to correct personal information so it is accurate, up to date, complete, relevant and not misleading for the purpose you hold it. Correction is free. 2
- Deletion · APP 11.2
- There is no right to erasure under the Privacy Act. APP 11.2 instead requires you to take reasonable steps to destroy or de-identify personal information you no longer need for any permitted purpose. The exceptions are a Commonwealth record, or information an Australian law or a court or tribunal order requires you to keep. The OAIC expects you to verify and document what you destroyed and when. 3, 4
So in Australia the delete workflows carry out a decision you have made under APP 11.2. They also serve requests under a regime with an erasure right, such as the GDPR.
Some of the work sits outside eDiscovery. Confirm the request comes from the person concerned, and ask for no more identity information than you need. If you refuse access in whole or part, send a written notice with your reasons and how to complain. 1
Correct information in the system that holds it: eDiscovery finds records but does not change them. 2, 5
Response time
- Agencies
- 30 calendar days
- to respond to an access or correction request, counted from the day after it arrives.
- Organisations
- A reasonable period
- which the OAIC says should generally not exceed 30 calendar days.
What you need in Purview first.
-
Role group · eDiscovery Manager
Lets you create cases, search, review and export. An eDiscovery Manager sees only the cases they create or are added to. 8
-
Role · Search And Purge
Needed for every purge, by Graph or PowerShell. It comes with the Organization Management role group in the Microsoft Purview portal, and the Teams deletion procedure also lists Data Investigator. Assign the role directly to the one person who runs deletions, and review who else holds it.
Exchange Online has its own Organization Management group, which doesn’t grant it. Without the Purview role, New-ComplianceSearchAction fails with “A parameter can’t be found that matches parameter name ‘Purge’”.
The Graph purgeData reference names only the Organization Management role group. If you grant Search And Purge another way, confirm that the account can purge before the day you need it. 8, 25, 26, 31
-
Role · Legal Hold
An Exchange Online role. Workflow 06 needs it to clear a delay hold with Set-Mailbox -RemoveDelayHoldApplied. 27
-
Licence · premium features
Review sets, tagging, redaction, the Identifier condition and the Graph purge need a case with premium features. A review set is a copy of search results you can tag, redact and export. The Identifier condition searches on exact message IDs.
Everyone whose content you search needs E5, or E1 or E3 with Microsoft Purview Suite or the eDiscovery and Audit add-on. That covers mailbox and OneDrive owners, and the owners and members of the sites, chats and channels you search. The administrator running the case needs a licence too. A tenant-wide search covers almost everyone, so check licensing first. 6, 7, 9, 13, 25
-
Holds
A hold keeps what a purge deletes, and search and purge isn’t supported on a mailbox under Litigation Hold. Check every mailbox you will purge in Exchange Online PowerShell.
Newer retention policies for Teams chats and Teams private channel messages don’t show in InPlaceHolds. Check those with Policy lookup in the Purview portal or Get-AppRetentionCompliancePolicy.
Exchange Online PowerShell · replace the mailbox Get-Mailbox {mailbox} | Format-List LitigationHoldEnabled,InPlaceHolds,DelayHoldApplied,DelayReleaseHoldApplied,ComplianceTagHoldApplied Get-OrganizationConfig | Format-List InPlaceHoldsReading InPlaceHolds
Prefix Hold Clear it in UniH eDiscovery case hold The case’s hold policies, in eDiscovery cld Cloud attachment hold The case’s hold policies, in eDiscovery mbx Retention policy for the mailbox Retention policies, in data lifecycle management skp Retention policy for Skype for Business Retention policies, in data lifecycle management grp Retention policy for Microsoft 365 groups and Teams channels Retention policies, in data lifecycle management -mbx Mailbox already excluded from a tenant-wide policy Nothing to clear Look up a UniH GUID with Get-CaseHoldPolicy, and an mbx, skp, grp or -mbx GUID with Get-RetentionCompliancePolicy. Find a cld hold by checking each case’s Hold policies for the mailbox. Pass each GUID without the prefix, and without the :1, :2 or :3 at the end, which names the policy’s retention action. An empty InPlaceHolds on the mailbox doesn’t mean no hold, because organisation-wide policies show only in Get-OrganizationConfig.
ComplianceTagHoldApplied set to True means a retention label was applied in the mailbox, and the mailbox is treated as on hold. It stays True after the labels are gone, until you reset it (workflow 06, step 3).
Removing a hold sets DelayHoldApplied to True for 30 days, and the mailbox stays on hold until it clears. Excluding a mailbox from an organisation-wide policy can take 24 hours. A policy with Preservation Lock can’t be removed or excluded, so its mailboxes can’t be cleared. Check holds before you promise anyone a deletion. 25, 26, 27, 28, 29
-
For files · an app registration
Workflow 04 runs a PowerShell script as an Entra app with the Microsoft Graph application permissions Files.ReadWrite.All and Sites.Read.All, with admin consent. Create it before the day you need it. 35, 38
Find the person’s data, review it and export the reply.
Every request
One case per request keeps the search, the review and the export together. It also gives you a record of what was found and what was released.
-
Create the case
eDiscovery › Cases › Create case
Give the case a name and a description, then select Create. Case names must be unique across the organisation, so use your request reference rather than the person’s name. 8, 10
Check The case opens on its own page.
The New case dialog, opened from Cases in eDiscovery. The demo cases are named after a person; name yours by reference. -
Create a search
Your case › Searches › Create a search
Name the search for what it does, such as the reference followed by “access”, and add a short description. Search names must also be unique across the organisation. 11
Check The search opens on its Query tab.
The case page. Searches lists every search in the case. Name the search for its purpose. -
Add the data sources
Query › Add tenant-wide sources
Add tenant-wide sources to search every Exchange mailbox, OneDrive and SharePoint site. Or select Add sources and add the person’s mailbox, their OneDrive and any site URLs you know hold their data.
A tenant-wide search also finds the person in other people’s mail and files, which an access request usually needs. If the person may be a guest, a departed employee or an unlicensed user, turn on those options in the tenant-wide sources.
For someone who has left, add their OneDrive by its URL, because it may no longer be linked to their account. Add their inactive mailbox explicitly too: adding a mailbox doesn’t mean its inactive mailbox is searched. 11, 12
Check The sources appear in the Data sources pane.
Tenant-wide sources cover every mailbox, OneDrive and SharePoint site. -
Build the query
Condition builder › Add conditions › KeyQL
Add a KeyQL condition that finds the person by name, by email address, or as a participant in mail. KeyQL is the keyword query language eDiscovery uses. The participants property covers From, To, Cc and Bcc.
Then add a Date condition for the period the request covers. For email, Date is when the message was sent or received; for files, when they were last modified. Searches run in UTC. APP 12 covers all the personal information you hold, so a narrower range is a scoping decision: record it in the case.
Don’t type (c:c) into the query: the portal adds it to join the conditions you build. Leave out any (-participants=…) clause a template or a Priva query carries, because it excludes items the address took part in. 1, 11, 13, 14
KeyQL condition · replace the name and address "Jordan Lee" OR "jordan.lee@contoso.com" OR participants:jordan.lee@contoso.comTip
Add every address, alias and earlier name you know for the person. eDiscovery can’t expand a participant it can’t find in Entra ID, such as a customer, or a former employee whose mailbox wasn’t kept as an inactive mailbox.
-
Run the query
Run query
Select Run query and keep the default result settings unless you need something else. 11
Choose which results to generate, then run. -
Read the statistics
Statistics
Check total matches, how many locations had hits and which data sources they came from. If one location dominates or the counts look wrong, change the query or the sources and run it again. 11
Check The counts match what you expect for this person.
Statistics are estimates. Check them before you copy anything into a review set. -
Add the results to a review set
Add to review set
Choose Add to a new review set and name it for the request. Keep the default, Add all search results to review set, rather than a sample. Items copied into a review set stay there until the case itself is deleted. 16, 17
Copy the search results into a new review set. -
Open the review set
Review sets › Your review set
Open the review set and browse the items. Confirm the search found the person’s data and not a different person with a similar name. 20
The case’s review sets. -
Tag every item
Manage › Tags
Create a tag group set to Single-select, with tags such as Release, Withhold, Delete and Not about the person, so every item gets one decision. A single-select tag can be changed to another tag in its group but not removed, so give every possible decision a tag.
Then select items, select Tag files, and choose Apply tags. 18
Create the tags once per case. Select items, then apply a tag from the Tag files pane. -
Filter by tag
Query › Tags
Filter the review set on the Tags condition to list what is ready to release. Use Is empty on the same condition to find anything nobody has tagged. 19
Check No item is left untagged.
The review set filtered to one tag. -
Redact what you withhold
Open an item › Annotate › Area redaction
Under APP 12 you withhold another person’s information, or confidential information, only where a ground for refusing access applies. Redacting it is a partial refusal, so it needs the written notice described above. Open the item, select Annotate, and draw an Area redaction over that content.
Commit the redactions in the review set before you export. Until you do, they don’t change the item in the review set, in search results or in exports. Committing produces a redacted PDF of the item, named after its ID with _burn.pdf on the end. 1, 5, 20
The Annotate tab. Area redaction draws a solid block over a region. An area redaction over part of a demo spreadsheet. -
Export from the review set
Select items › Action › Export
Select the items tagged for release, then Export. Choose Export items with item report, tick Export redaction, or the package carries the originals, and tick Export tags so the report records each decision.
Leave the options to expand the selection to associated family and conversation items off: they can add items you tagged Withhold. Don’t export redacted email as a PST, because a PST can’t carry the redacted PDFs. Choose Create .msg files for messages instead. 21
Watch out
For a Teams or Viva Engage thread with redactions, the package holds the redacted PDF and the original conversation file. Remove the original before anything goes to the requester.
Export starts from the Action menu. Tick Export redaction, or the redactions stay behind. In this demo run the expand option is on and Export tags is off: set both as the step says. -
Download the packages
Exports › Your export › Download packages
Select the export, then each package, and download it. Download review set exports within 30 days. Package links are for individual use, so send the requester files, never a link.
In our runs the packages arrive as Items-, PSTs- and Reports- zip files: files, email and the item report. 21, 22
Tip
Unzip with 7-Zip or a similar tool. Microsoft advises against the built-in Windows zip utility, which can change file properties such as dates.
A completed export. Download each package. The files package, unzipped. The email package from an unredacted demo export, a PST. The reports package: Items, Locations, Settings and Summary CSVs. -
Keep the item report
Reports package › Items CSV
The Items CSV lists every item the export processed, including any that failed. Check its Status column, then keep it with the request as your record of what was found and released. 23, 24
Check Every item you released shows as exported, with its message ID or file path in the Identifier column.
The Items CSV. The highlighted Identifier column holds each email’s message ID and each file’s path. The script in workflow 04 reads a different column, SPO document link.
Delete specific email messages with a Graph purge.
Only if you have decided to delete email
A purge deletes whatever the search returns. So the search must return exactly the messages to delete and nothing else, and you check every one of them before you send the request.
Before you purge
- A purge can’t be undone.
- Check every mailbox for holds first (see Holds above). If any hold applies, don’t purge that mailbox here: use workflow 06 for it. A purge leaves held messages in Recoverable Items, and 06 removes the holds and the delay hold, purges, then puts every hold back. Search and purge isn’t supported under Litigation Hold.
- Each purge removes up to 100 items per mailbox. Purge is an event-response tool, not a mailbox clean-up: Microsoft advises against running purge after purge to get round the limit. If more than 100 messages in one mailbox must go, plan another route with your Exchange administrator.
- Use a case with premium features. Without them, use PowerShell instead (see Limits). Never combine PowerShell and Graph purges.
-
Create a search for the deletion
Your case › Searches › Create a search
Create a new search in the request’s case and name it for the purge, so it is never confused with the access search. 11
A separate search, named for the deletion. -
Add the message IDs
Condition builder › Add conditions › Identifier
Take the message IDs from the email you tagged Delete, not from the access export, which lists what you released. In the review set from workflow 01, filter on the Delete tag, select the email and export it with its item report, with the options to expand the selection off.
Copy each message ID from the Identifier column of that export’s Items CSV and add every one to an Identifier condition. Identifier is a premium condition: in a case without premium features, a purge based on it can delete more than you meant.
A purge deletes every copy the search finds, so each recipient’s copy of the message goes too. Record that in your decision. 11, 13, 21, 25
Watch out
Never purge from a search whose condition is empty. An empty keyword condition returns everything in the selected sources.
-
Add the mailboxes
Query › Add sources
Add only the mailboxes that hold the messages. A search used for purge can include mailboxes and public folders only, so leave sites out. 25
-
Run the query
Run query
Run the query. If the portal reports a syntax error, fix it before you go on. 11
-
Check the statistics
Statistics
Confirm the total and that each hit is in a mailbox you expect. A message counts once for every mailbox that holds a copy of it. 25
Check Total matches is one for each copy of each message, in the mailboxes you added.
One message, in one mailbox. This demo search covered every mailbox in the tenant; yours adds only the mailboxes that hold the messages. -
Read the sample
Sample
Open Sample and read the items it shows. The sample is a selection, so the next step checks the rest. 25
Read the message before you delete it. -
Export a report of what will be deleted
Your deletion search › Export › Export items report only
Export the deletion search as a report only, download the reports package, and read every row of the Items CSV. Every row is a message the purge will delete.
A purge removes at most 100 items in each mailbox. If any mailbox has more than 100 rows, stop and plan another route (see Before you purge). If a row’s path is in Recoverable Items, a hold probably applies: check that mailbox’s holds again and use workflow 06 for it. 22, 25
Check Every row is a message you mean to delete, no mailbox has more than 100 rows, and the row count matches the statistics.
-
Sign in to Graph Explorer
Graph Explorer › Sign in
Open Microsoft Graph Explorer and sign in with the account that holds Search And Purge. Set the version to v1.0. 31
Graph Explorer before sign-in. -
Consent to the eDiscovery permissions
Modify permissions
Open Modify permissions and consent to eDiscovery.Read.All and eDiscovery.ReadWrite.All if they are not already consented. The purge itself needs eDiscovery.ReadWrite.All. Where the tab shows Admin consent required, an administrator who can grant tenant-wide consent approves them first. 31, 33
The purge needs eDiscovery.ReadWrite.All. -
Find the case ID
Run the request below and copy the id of the case whose displayName matches yours. Or open the case in the Purview portal and copy the ID from its address. 33
Graph · v1.0 GET https://graph.microsoft.com/v1.0/security/cases/ediscoveryCasesThe case list. Copy the id. -
Find the search ID
List the case’s searches and copy the id of the deletion search, matched on displayName. Check its contentQuery: the purge deletes whatever that query returns, so it must be the query you reviewed. 34
Graph · v1.0 GET https://graph.microsoft.com/v1.0/security/cases/ediscoveryCases/{caseId}/searchesThe case’s searches. Copy the deletion search’s id. -
Run the purge
Post purgeData against the search. Set purgeAreas to mailboxes and purgeType to permanentlyDelete. The other purgeType is recoverable. 31, 32
Graph · v1.0 POST https://graph.microsoft.com/v1.0/security/cases/ediscoveryCases/{caseId}/searches/{searchId}/purgeData { "purgeType": "permanentlyDelete", "purgeAreas": "mailboxes" }Check Graph answers 202 Accepted with a Location header. Send GET to that URL until status is succeeded. partiallySucceeded or failed means some items stayed. Download the purge report that reportFileMetadata links, and keep it with your record: the status and the report, not a second search, show what was deleted.
What it cannot reach
Purge reaches Exchange Online mailboxes and public folders only. It can’t delete files in OneDrive or SharePoint, and it can’t delete the copies in a review set: those go when the case is deleted.
Delete Teams chat messages with a Graph purge.
Only if you have decided to delete Teams chats
eDiscovery finds Teams messages through the compliance copies kept in mailboxes. So the search runs against mailboxes, and the purge uses the same Graph call with a different purge area.
Before you purge
- Teams messages are always permanently deleted, whichever purgeType you send.
- Check the target mailboxes for holds (see Holds above). Remove every hold first, as in workflow 06 steps 1, 3 and 4: record them, remove them, and clear the delay hold. Otherwise the messages are kept. Newer Teams chat retention policies don’t show in InPlaceHolds (see Holds above). Reapply them once the messages are gone from Teams: a hold reapplied within 24 hours might keep the compliance copy.
- Each purge removes up to 100 items per mailbox.
- Purge isn’t supported for chats with external or federated users, or for chats with yourself.
-
Create a search for the deletion
Your case › Searches › Create a search
Create a search in the request’s case and name it for the Teams purge. 11
A separate search for the Teams purge. -
Narrow the query to Teams messages
Condition builder › Add conditions › Type
Add a Type condition set to Instant messages, so the search returns chat messages only. Then add a KeyQL condition that identifies only the messages to delete, and a Date condition. A sender alone returns every chat message that person sent. 13, 26
KeyQL condition · replace the address and narrow it from:jordan.lee@contoso.com -
Check the statistics
Statistics
Check the total and the locations. Change the query until the count is only what should go. 26
The count before the purge, from another test search in the same demo tenant. -
Read the sample
Sample
Open Sample and read the messages it shows. The sample is a selection, so the next step checks the rest. 26
-
Export a report of what will be deleted
Your deletion search › Export › Export items report only
Export the deletion search as a report only, download the reports package, and read every row of the Items CSV. Every row is a message the purge will delete. 22, 26
Check Every row is a message you mean to delete, and the row count matches the statistics.
-
Sign in to Graph Explorer
Graph Explorer › Sign in
Sign in with the account that holds Search And Purge, and set the version to v1.0. 31
Graph Explorer before sign-in. -
Consent to the eDiscovery permissions
Modify permissions
Consent to eDiscovery.Read.All and eDiscovery.ReadWrite.All if they are not already consented. Where admin consent is required, an administrator who can grant it approves them first. 31
The same permissions as for email. -
Find the case ID
List the cases and copy the id of yours, or copy it from the case’s address in the Purview portal. 33
Graph · v1.0 GET https://graph.microsoft.com/v1.0/security/cases/ediscoveryCasesCopy the case id. -
Find the search ID
List the case’s searches and copy the id of the Teams deletion search. Check that its contentQuery is the query you reviewed. 34
Graph · v1.0 GET https://graph.microsoft.com/v1.0/security/cases/ediscoveryCases/{caseId}/searchesCopy the search id, and read the contentQuery beside it before you purge. -
Run the purge
Post purgeData with purgeAreas set to teamsMessages. People then see “This message was deleted by an admin” in place of each message.
A compliance copy stays in the mailbox for at least 24 hours and is usually gone within one to seven days. 26, 31, 32
Graph · v1.0 POST https://graph.microsoft.com/v1.0/security/cases/ediscoveryCases/{caseId}/searches/{searchId}/purgeData { "purgeType": "permanentlyDelete", "purgeAreas": "teamsMessages" }Check Graph answers 202 Accepted. Poll the Location URL until status is succeeded, and keep the purge report that reportFileMetadata links. A search can still find the compliance copies until they go, within one to seven days.
Delete files in OneDrive and SharePoint with the deletion script.
Only if you have decided to delete files
eDiscovery purge does not reach OneDrive or SharePoint. The script works through the files listed in a review set export’s Items CSV and deletes each one with Microsoft Graph driveItem permanentDelete.
Before you run the script
- The script deletes permanently. Files skip the recycle bin and can’t be restored from it.
- It reads the SPO document link column of the Items CSV. Only a review set export fills that column.
- We recommend deleting only files that are wholly the person’s information and no longer needed. Edit a shared document that only mentions them in place.
- A file under a retention policy or a retention label is copied to the site’s Preservation Hold library when it is deleted, so a copy stays until that retention ends. Nothing under an eDiscovery hold is permanently deleted while the hold applies.
- A file labelled as a record, whether or not the record is locked, or as a regulatory record can’t be deleted. A tenant setting can also block deleting files that carry a standard retention label. The script reports these files as failed.
-
Export the files to delete
Review set › Query › Tags
In the review set from workflow 01, filter on the Delete tag and select the files. Export them with Export items with item report and the options to expand the selection off, as in workflow 01. Then download the reports package.
Don’t use Export items report only here: it cuts every text field to 255 characters, which can truncate the SPO document link. And don’t reuse the access export, which holds only what you released. 21, 22
-
Unzip it
Extract the Reports- zip file to a folder you control, with 7-Zip or a similar tool. 22
-
Remove the files you must keep
Delete the row of every file you must keep. Keep a file if you still need it for a purpose you hold it for, or it is part of a Commonwealth record. Keep it too if an Australian law or a court or tribunal order requires it. What is left is the deletion list. Save it as CSV UTF-8.
In our runs, email and Teams rows had no file link, so the script skipped them. Rows for cloud attachments can link to a shared file, so check every remaining link is a file you mean to delete. 3, 24
Check Every remaining row with a file link is a file you mean to delete.
An Items CSV from the demo tenant before cleaning: three files and one email. The script skips the email row, which has no file link. -
Register the app
Entra admin centre › App registrations › New registration
Register an app, add a client secret, and copy the secret’s value straight away. It is shown only once.
Under API permissions, add the Microsoft Graph application permissions Files.ReadWrite.All (to find and delete the files) and Sites.Read.All (to resolve each site and list its libraries), then grant admin consent. 35, 38
Watch out
This app can delete any file in the tenant. Give the secret a short expiry, store it in a password manager, and delete the secret when the request is closed.
Add a client secret with a short expiry. Copy the value now. It is not shown again. -
Run the script
In PowerShell 5.1 or later, run the script with the path to your CSV, the tenant ID and the app’s client ID. It asks for the client secret at a hidden prompt, lists every file, and waits for you to type YES in capitals.
For each link it finds the site and the library the link names, checks that the item is a file whose name matches the link, and only then deletes it. Anything else is refused and left alone. 35, 38
PowerShell · replace the path and IDs .\srr-playbook-delete-odsp-files.ps1 ` -DocumentLinksFile "C:\SRR\Items_0_{timestamp}.csv" ` -TenantId "{tenant-id}" ` -ClientId "{client-id}"Check The summary shows each file as deleted, not found, refused or failed, and DeletionReport_{timestamp}.csv in the current folder has one row per file. Check every Not found and Refused row by hand.
The deletion script
Download the deletion scriptPowerShell · 22 KB · version 1.3-lensiq
- Based on Microsoft’s MIT-licensed sample, version 1.1.
- The secret is asked for at a hidden prompt, so it stays out of shell history.
- Each link is matched to its own library, so files outside Shared Documents, on subsites and in any OneDrive are found.
- Version 1.3 encodes each part of the path, so a name containing #, ? or % can’t resolve to its folder, and it refuses any item that isn’t a file with the linked name. Version 1.2 did neither: don’t run it.
- The report is written row by row, so an interrupted run still leaves a record.
- Links on the tenant’s root site aren’t supported and fail. Delete those files, and any Refused row, by hand.
- Read the script before you run it. Test it on one file first.
What it cannot reach
The script reaches only the files linked in the SPO document link column. It doesn’t touch the copies kept in a Preservation Hold library or a review set. Each file it deletes is gone for good: keep the cleaned CSV and the DeletionReport CSV together as the record.
Copy the query from a case opened in Priva.
Only if the request was opened in Priva Subject Rights Requests
If a request was opened in Priva Subject Rights Requests, you can reuse its search in eDiscovery. The query is in the Priva page’s network traffic. This is a practitioner workaround, not a Microsoft procedure, and it works only while your tenant can still open the Priva page.
Before you start
- The network response holds personal information for every case listed. When you are done, clear the Network list and close the developer tools.
-
Open the developer tools
Priva › Subject rights requests › Inspect
Open the Priva subject rights requests page. Right-click the page and select Inspect.
Open the browser’s developer tools on the Priva page. -
Filter the network traffic
Network › Filter
Select the Network tab, type privacycases in the filter box, and reload the page.
Filter on privacycases. -
Turn on the Priva view
If the page has moved you to eDiscovery and offers a toggle to use Subject Rights Requests in Microsoft Priva, switch it on. A privacycases request appears in the Network list.
The toggle back to the Priva view. -
Copy the filterQuery
privacycases › Response
Select the request and open Response. Press Ctrl+F, search for the case name, and copy the value of filterQuery for that case.
The case record and its filterQuery. -
Remove the escape characters
The copied query has a backslash before every quotation mark. Remove them, and leave out the (c:c) and (-participants=…) clauses at the end. Paste the rest into a KeyQL condition in workflow 01 and add the date as a Date condition. 13
As copied, then cleaned ((\"Jordan Lee\" OR \"jordan.lee@contoso.com\") OR (participants:\"jordan.lee@contoso.com\"))(c:c)(-participants=jordan.lee@contoso.com) (("Jordan Lee" OR "jordan.lee@contoso.com") OR (participants:"jordan.lee@contoso.com"))Check The eDiscovery count is the same as or higher than Priva’s: the clauses you left out narrowed Priva’s search.
Clear held email from Recoverable Items.
Only if a mailbox holding email you will delete has a hold
A hold keeps deleted messages in the mailbox’s Recoverable Items folder, and a purge leaves them there while any hold applies. Use this workflow instead of 02 for any mailbox with a hold, from Exchange Online PowerShell and Security & Compliance PowerShell. Never combine it with a Graph purge on the same messages. Never use it for Teams messages: a PowerShell purge can remove the compliance copy, leave the message visible, and stop a later Graph purge. Keep AND kind:email in the query so Teams items stay out. You change the mailbox, remove its holds, purge, then put it back exactly as it was. Allow a day or more: several changes take hours to apply.
Before you start
- Get written agreement from records management or legal before you remove a hold. Your organisation may have a policy that says whether the hold or the deletion comes first.
- This procedure isn’t supported for inactive mailboxes: a hold removed from one can’t be put back, and the mailbox is then permanently deleted.
- It can’t be done on a mailbox under a retention policy with Preservation Lock.
- For items under a hold, Microsoft strongly recommends Priority Cleanup in data lifecycle management. This workflow is the other route Learn documents: release the holds, purge, then put them back.
- To search you need eDiscovery Manager or the Compliance Search role, and to delete, Search And Purge. In Exchange Online you need an administrator account with the roles to change mailbox and client access settings, and Legal Hold to clear a delay hold.
- The mailbox owner loses access until the last step. Tell them before you start.
-
Record the mailbox settings
Connect to Exchange Online PowerShell and save the output of these commands to a text file. You change several of these settings and put them back from this record in step 7.
If InPlaceHolds is cut short, run Get-Mailbox {mailbox} | Select-Object -ExpandProperty InPlaceHolds to list each value on its own line. Read each value by its prefix, as in Holds, under What you need in Purview first. Run the last command again with -Archive if the mailbox has an archive. 27
Exchange Online PowerShell · replace {mailbox} Get-Mailbox {mailbox} | Format-List SingleItemRecoveryEnabled,RetainDeletedItemsFor Get-CASMailbox {mailbox} | Format-List EwsEnabled,ActiveSyncEnabled,MAPIEnabled,OWAEnabled,ImapEnabled,PopEnabled Get-Mailbox {mailbox} | Format-List LitigationHoldEnabled,InPlaceHolds,ComplianceTagHoldApplied Get-OrganizationConfig | Format-List InPlaceHolds Get-Mailbox {mailbox} | Format-List DelayHoldApplied,DelayReleaseHoldApplied Get-MailboxFolderStatistics {mailbox} -FolderScope RecoverableItems | Format-List Name,FolderAndSubfolderSize,ItemsInFolderAndSubfoldersCheck Your text file holds every value, and you know which holds apply to the mailbox.
-
Prepare the mailbox
Turn off client access, raise the deleted item retention period to 30 days, turn off single item recovery, and stop the Managed Folder Assistant processing the mailbox. The first command assumes every access method was on; turn off only those your record shows as True.
Client access can take up to 60 minutes to turn off and doesn’t sign out someone already signed in. Single item recovery can take up to 240 minutes. 27
Exchange Online PowerShell · replace {mailbox} Set-CASMailbox {mailbox} -EwsEnabled $false -ActiveSyncEnabled $false -MAPIEnabled $false -OWAEnabled $false -ImapEnabled $false -PopEnabled $false Set-Mailbox {mailbox} -RetainDeletedItemsFor 30 Set-Mailbox {mailbox} -SingleItemRecoveryEnabled $false Set-Mailbox {mailbox} -ElcProcessingDisabled $trueWatch out
Don’t purge until 240 minutes have passed since you turned off single item recovery. Items deleted before then are kept.
-
Remove the holds
Data lifecycle management › Retention policies › Your policy › Edit
Remove every hold your record found. For Litigation Hold, run the first command. For a retention policy (mbx, skp or grp), find its name with Get-RetentionCompliancePolicy, then remove the mailbox from the policy. For an organisation-wide policy, add the mailbox to the policy’s excluded recipients instead. For an eDiscovery case hold (UniH) or a cloud attachment hold (cld), find the case and the hold, then remove the mailbox from that hold in the case.
Use each GUID without its prefix and without the :1, :2 or :3 at the end. Run the last three commands in Security & Compliance PowerShell. 27, 28, 29
Litigation Hold, then the policy and case names Set-Mailbox {mailbox} -LitigationHoldEnabled $false Get-RetentionCompliancePolicy {policy-guid} | Format-List Name $CaseHold = Get-CaseHoldPolicy {hold-guid} Get-ComplianceCase $CaseHold.CaseId | Format-List NameCheck Run the step 1 commands again: LitigationHoldEnabled and ComplianceTagHoldApplied are False, and InPlaceHolds lists no hold you removed. Removing Litigation Hold can take up to 240 minutes, and an exclusion from an organisation-wide policy up to 24 hours.
Watch out
If ComplianceTagHoldApplied is True, a retention label may be keeping items. Find labelled items with the Retention label condition in a search and deal with them first. The value stays True after the labels are gone. Once none remain, reset it with Set-Mailbox {mailbox} -RemoveComplianceTagHoldApplied -ProvideConsent.
-
Remove the delay hold
Once a hold is removed, the Managed Folder Assistant sets DelayHoldApplied or DelayReleaseHoldApplied to True for 30 days, and the mailbox stays on hold. If either is True, clear it. You need the Legal Hold role in Exchange Online. 27
Exchange Online PowerShell · run the one that is True Set-Mailbox {mailbox} -RemoveDelayHoldApplied Set-Mailbox {mailbox} -RemoveDelayReleaseHoldAppliedCheck Get-Mailbox {mailbox} | Format-List DelayHoldApplied,DelayReleaseHoldApplied shows both as False.
-
Find and delete the items
In Exchange Online PowerShell, list what is in Recoverable Items with Get-RecoverableItems {mailbox}, and note what the messages you mean to delete have in common: subject, sender and date. Build a search in Security & Compliance PowerShell on those properties, with AND kind:email, and check that it returns only those messages. The search covers the whole mailbox, not only Recoverable Items, so anything else it matches is deleted too.
Each purge deletes up to 10 items in the mailbox. To delete more, remove the finished purge action and start another. Repeat until the search returns none of them. 25, 27
Security & Compliance PowerShell · replace the query and {mailbox} Connect-IPPSSession -EnableSearchOnlySession New-ComplianceSearch -Name "RecoverableItems" -ExchangeLocation {mailbox} -ContentMatchQuery 'subject:"{subject}" AND from:{sender} AND kind:email' Start-ComplianceSearch -Identity "RecoverableItems" Get-ComplianceSearch -Identity "RecoverableItems" | Format-List Status,Items New-ComplianceSearchAction -SearchName "RecoverableItems" -Purge -PurgeType HardDelete Get-ComplianceSearchAction -Identity "RecoverableItems_Purge" | Format-List Status Remove-ComplianceSearchAction -Identity "RecoverableItems_Purge"Check Get-ComplianceSearchAction shows each purge action finished before you remove it and start the next.
Watch out
HardDelete can’t be undone. If any hold still applies, the purge reports success and leaves the items where they are.
-
Check they are gone
Run the step 5 search again, then compare the Recoverable Items size and item count with the figures you recorded in step 1. Add -Archive for the archive. 27
Exchange Online PowerShell Get-MailboxFolderStatistics {mailbox} -FolderScope RecoverableItems | Format-List Name,FolderAndSubfolderSize,ItemsInFolderAndSubfoldersCheck The search returns none of the messages, and the Recoverable Items count has dropped by the number that were there.
-
Put the mailbox back
Work in this order. Set the deleted item retention period back to the value in your record, and turn single item recovery and client access back on. Then reapply every hold you removed in step 3. For policies and case holds, add the mailbox back in the Purview portal.
Wait 24 hours after the holds are back and confirmed, then let the Managed Folder Assistant process the mailbox again. 27
Exchange Online PowerShell · use the values in your record Set-Mailbox {mailbox} -RetainDeletedItemsFor {days} Set-Mailbox {mailbox} -SingleItemRecoveryEnabled $true # Turn back on only the methods your record shows as True Set-CASMailbox {mailbox} -EwsEnabled $true -ActiveSyncEnabled $true -MAPIEnabled $true -OWAEnabled $true -ImapEnabled $true -PopEnabled $true # Only if your record shows Litigation Hold Set-Mailbox {mailbox} -LitigationHoldEnabled $true # 24 hours after the holds are back Set-Mailbox {mailbox} -ElcProcessingDisabled $false Get-Mailbox {mailbox} | Format-List ElcProcessingDisabled,InPlaceHolds,LitigationHoldEnabled,RetainDeletedItemsFor,SingleItemRecoveryEnabled Get-CASMailbox {mailbox} | Format-List EwsEnabled,ActiveSyncEnabled,MAPIEnabled,OWAEnabled,ImapEnabled,PopEnabledCheck Every value matches your step 1 record, and ElcProcessingDisabled is False.
What it cannot reach
The Managed Folder Assistant doesn’t delete anything; only the purge in step 5 does. Items in an auxiliary archive, where auto-expanding archiving is on, aren’t deleted.
Limits and edge cases.
- Without premium features, purge email from Security & Compliance PowerShell instead. Use the Exchange Online PowerShell module 3.9.0 or later and connect with -EnableSearchOnlySession. Build the search on subject, sender and dates, never on an Identifier condition, with AND kind:email. Check its results with a report-only export, as in workflow 02. Rerun it in PowerShell, wait for it to complete, and check it returns the same results as in the portal: a search run in the portal shows an ItemCount of 0 there. Each purge removes up to 10 items per mailbox. Never use it for Teams messages: it can remove the compliance copy, leave the message visible, and stop a later Graph purge. It doesn’t delete unindexed items, and it fails if the search covers more than 50,000 mailboxes. With single item recovery on, a hard-deleted message is kept in the Purges folder for the deleted item retention period. 25, 26
Security & Compliance PowerShell · replace {search} Connect-IPPSSession -EnableSearchOnlySession Start-ComplianceSearch -Identity "{search}" Get-ComplianceSearch -Identity "{search}" | Format-List Status,Items # Once the search is complete and returns what you reviewed New-ComplianceSearchAction -SearchName "{search}" -Purge -PurgeType HardDelete Get-ComplianceSearchAction -Identity "{search}_Purge" | Format-List Status - Never combine PowerShell and Graph purges on the same content. Pick one route for each set of messages and record which. 25
- Microsoft built purge to respond to an event such as data spillage, not to clean up mailboxes. Record each purge as a decision, with the request it serves. 25
- Copilot prompts and responses are stored in mailboxes, so the same mailbox search finds them and an access request can include them. 5, 14
- Exporting SharePoint and OneDrive content needs a SharePoint E3 licence on the account that runs the export. 7, 22
- Processes, exports included, are cancelled if they haven’t finished after seven days. Start large exports early and check their status. 21, 23
- Every copy eDiscovery makes, in a review set or an export, is more personal information to look after. Delete the case once the request is closed and your record is kept elsewhere. Closing or deleting a case turns off its holds, so first check that nothing in it is held for another reason. 3, 10, 17
What you end up with.
- For the requester
- The exported files and email, with other people’s information withheld only where a refusal ground applies. Send files, never a package link.
- For your records
- The Items, Summary and Settings CSVs exported from the case, and your written decision on scope, refusals and deletion. The case itself is deleted once the request is closed.
- If you deleted
- For each purge: the report-only export you reviewed, the search query, and the final status of the purge operation with its report. For files, the cleaned CSV with the script’s DeletionReport.
- If you cleared a hold
- The sign-off from records management or legal, and your step 1 record of the mailbox settings. Add the same settings read back after step 7, and the Recoverable Items counts before and after.
Where each step comes from.
- 1 OAIC Chapter 12: APP 12 Access to personal information
- 2 OAIC Chapter 13: APP 13 Correction of personal information
- 3 OAIC Chapter 11: APP 11 Security of personal information
- 4 OAIC Australian entities and the EU General Data Protection Regulation
- 5 Microsoft Office 365 Data Subject Requests for the GDPR and CCPA
- 6 Microsoft Learn about eDiscovery (Features and capabilities)
- 7 Microsoft Get started with eDiscovery
- 8 Microsoft Assign permissions in eDiscovery
- 9 Microsoft Microsoft Purview service description
- 10 Microsoft Create and manage cases in eDiscovery
- 11 Microsoft Create a search for a case in eDiscovery
- 12 Microsoft Data sources in eDiscovery
- 13 Microsoft Use the condition builder to create search queries in eDiscovery
- 14 Microsoft Finding content in mailboxes in eDiscovery
- 15 Microsoft Finding content in Microsoft Teams in eDiscovery
- 16 Microsoft Add search results to a review set in eDiscovery
- 17 Microsoft Manage review sets in eDiscovery
- 18 Microsoft Tag items in a review set in eDiscovery
- 19 Microsoft Search content in a review set
- 20 Microsoft Group and view items in a review set in eDiscovery
- 21 Microsoft Export items from a review set in eDiscovery
- 22 Microsoft Export search results in eDiscovery
- 23 Microsoft Use Process reports in eDiscovery
- 24 Microsoft Document metadata fields in eDiscovery
- 25 Microsoft Find and delete email messages in eDiscovery
- 26 Microsoft Find and delete Microsoft Teams chat messages in eDiscovery
- 27 Microsoft Delete items in the Recoverable Items folder for mailboxes on hold in eDiscovery
- 28 Microsoft Identify Exchange mailbox hold types in eDiscovery
- 29 Microsoft Manage hold policies for eDiscovery cases
- 30 Microsoft Limits in eDiscovery
- 31 Microsoft ediscoverySearch: purgeData (Microsoft Graph v1.0)
- 32 Microsoft ediscoveryPurgeDataOperation resource type (Microsoft Graph v1.0)
- 33 Microsoft List ediscoveryCases (Microsoft Graph v1.0)
- 34 Microsoft List searches (Microsoft Graph v1.0)
- 35 Microsoft driveItem: permanentDelete (Microsoft Graph v1.0)
- 36 Microsoft Learn about retention for SharePoint and OneDrive
- 37 Microsoft Records management for documents and emails in Microsoft 365
- 38 Microsoft Get a site resource by path (Microsoft Graph v1.0)
Version history
- Version 2.2 Re-audited against Microsoft Learn and the OAIC. Added a report-only export before every purge, the purge status values, holds and delay holds in full, and workflow 06 for held email in Recoverable Items. Restated licensing and roles. Fixed the deletion script as version 1.3, and removed 13 screenshots that no longer matched their steps.
- Version 2.1 Code boxes with a Copy button, Tip and Watch out callouts, and click paths that copy cleanly.
- Version 2.0 Rebuilt from the full playbook: demo tenant screenshots for every step, the file deletion script as a download, and the Priva query workflow.
- Version 1.0 First version, from the playbook text, checked against Microsoft Learn and the OAIC.
Have LensIQ set this up in your tenant.
LensIQ sets up the roles, the case conventions, the tags and the deletion app, and checks that holds and licences won’t stop a request halfway.