Reading width
Wide uses the full column for everything, text, diagrams, code, and exercises. Narrow keeps the standard reading width.
Text size
Scales the body text. Headings and code blocks keep their size.
In this section
Preserving Microsoft 365 Evidence: Holds, Exports, Hashes and Custody
Introduction
The records in a tenant are not evidence until somebody makes them so. They sit in Microsoft's systems, ageing toward deletion, readable by anyone with the right role, and changeable in the sense that the objects they describe can be altered or removed at any moment. An inbox rule the attacker created can be deleted by the attacker, by the user or by a well-meaning administrator before anyone records what it said.
Turning records into evidence means three things: preserving what would otherwise be lost, collecting copies into storage you control, and recording enough about each copy that someone else can trust it and repeat it. None of it is complicated. All of it is easy to get wrong under pressure, and mistakes here cannot be fixed later.
This lesson covers what distinguishes evidence from a record, why preservation comes first, how holds keep what gets deleted, how to inventory the evidence for one incident, exporting, what a hash proves and does not prove, and custody when the original never leaves the provider.
A Record Is Not Yet Evidence
Provenance is what changesA record becomes evidence when it has been collected for a purpose and can be shown to be what it claims to be. In practice that comes down to provenance: being able to say where the copy came from, how it was obtained, when, by whom, and that it has not changed since.
The test is whether somebody who was not there could repeat the collection and get the same result, or at least understand exactly why they would not. A screenshot of a portal page with no date, no filter and no note of who took it fails that test, even when what it shows is perfectly true. A CSV exported by a named query, run at a recorded time, with its hash noted, passes it.
Provenance note, one exported item
Item
OfficeActivity records for c.richardson@ne.com, 27 February to 4 March 2026
Source
Sentinel workspace, OfficeActivity table
Query
saved verbatim in the case folder as q-017.kql
Run at, by
2026-03-05 09:42 UTC, investigator account
Result
128 records, exported to CSV, SHA-256 recorded
Nobody in a small team will produce a note like this for every query they run while exploring, and they should not have to. The discipline applies to what the investigation relies on: the records behind a finding, a timeline entry, a containment decision or a statement to a regulator. Exploration is free. Anything a conclusion rests on gets collected properly.
Screenshots deserve a specific word, because they are what people reach for first. A screenshot is useful as an illustration in a report, showing a reader what a portal displayed. As evidence it is weak: it captures only what fitted on the screen, it carries no machine-readable data, it can be edited without trace, and it rarely records the filter or time zone that produced it. Take the screenshot if it helps someone understand, and export the records it shows as well.
The reason this matters is less often a courtroom than people imagine and more often a question nobody expected. An insurer asks for the basis of the scope statement. A regulator asks why the notification said fifty mailboxes. A colleague revisiting the case in six months asks why a user was cleared. In each case the answer is the collected evidence and its notes, and a finding nobody can trace back to its records is just an opinion.
Preserve Before You Collect
Stop the loss firstThe order of operations in a tenant is the reverse of instinct. The instinct is to start searching, find out what happened, and keep what turns out to matter. The correct order is to first stop anything from being lost, and only then start working out what happened.
Three kinds of loss threaten tenant evidence. Expiry: a log reaching the end of its retention period, which for Entra ID sign-ins may be days away. Deletion: an attacker or a user removing mail, files or rules. Remediation: the response itself removing the attacker's artifacts, a forwarding rule deleted or an application removed, before anybody captured what they were.
The third is the one responders cause themselves, and it is the commonest. An administrator who finds a malicious inbox rule and deletes it has done the right thing for containment and destroyed the only record of the rule's exact conditions, unless somebody captured them first. Capturing first takes seconds:
PS C:\> Connect-ExchangeOnline
PS C:\> Get-InboxRule -Mailbox c.richardson@ne.com |
Select-Object Name, Enabled, Priority, SubjectOrBodyContainsWords,
MoveToFolder, MarkAsRead, ForwardTo, RedirectTo, DeleteMessage |
Export-Clixml .\c.richardson-inboxrules-2026-03-05T0938Z.xml
The export keeps every property of every rule in a file that can be hashed, and only then is the rule removed. The same applies to anything containment will change: capture an application's permissions before deleting it, a user's authentication methods before resetting them, a mailbox's forwarding settings before clearing them.
Expiry is handled by exporting the records closest to their deletion date first. If the incident's earliest activity is twenty-five days ago and Entra ID keeps thirty days of sign-ins, that export is the first task of the morning, ahead of every interesting question.
Holds: Keeping What Gets Deleted
Mailboxes and sitesMail and files are different from logs: the content itself can be deleted, and a deleted message is often exactly what an investigation needs. An attacker running a payment fraud from a mailbox will commonly delete the replies they sent so the real owner does not see them. The course dataset records 142 HardDelete operations over its thirty days, most of them users tidying mail, and any one of them could be an attacker covering a conversation.
Exchange Online keeps deleted items for a period in each mailbox's Recoverable Items folder before purging them. A hold stops that purge: while a mailbox is on hold, items that are deleted or changed are kept in Recoverable Items rather than removed, and remain searchable for as long as the hold lasts.
The same deleted message, with and without a hold. A hold only works on what Recoverable Items still has when it lands.
Three mechanisms can be holding a mailbox. A Litigation Hold is set per mailbox and preserves everything in it. An eDiscovery hold is created in a Purview eDiscovery case, can cover mailboxes, OneDrive accounts and sites, and can be limited by a query or date range. A retention policy may already be preserving content organization-wide, so check what exists before adding anything.
Microsoft Purview
Microsoft Purview › eDiscovery › Cases › (case) › Hold policies › Create policy
Name the policy, then add the affected users as data sources and create it. Check the Details tab afterwards: a new hold can take up to 24 hours to take effect.
That delay is the reason holds go on early. A hold created at 09:00 may not be protecting the mailbox until the next morning, and anything purged in between is gone. Licensing is the other check: frontline plans such as Office 365 F1 and F3 do not include the rights to be placed on an eDiscovery hold.
A hold preserves from the moment it is applied, plus whatever Recoverable Items still holds. It does not bring back items that were already purged. How long Recoverable Items keeps deleted mail without a hold is a mailbox setting. By default Exchange Online keeps deleted items for fourteen days, and administrators can raise that to thirty. After that period, an item deleted from Recoverable Items is purged unless a hold or retention policy applies. An attacker who deleted a sent reply three weeks before the investigation started may already have outlasted the default.
One command shows where a mailbox stands before anything is changed:
PS C:\> Get-Mailbox -Identity c.richardson@ne.com |
Format-List LitigationHoldEnabled, InPlaceHolds, RetainDeletedItemsFor
LitigationHoldEnabled : False
InPlaceHolds : {}
RetainDeletedItemsFor : 14.00:00:00
This is a default mailbox: no Litigation Hold, no eDiscovery or in-place holds listed, and deleted items kept for fourteen days. Anything the attacker deleted more than fourteen days ago has already gone, and the clock is running on the rest. That is why placing affected mailboxes on hold is one of the first actions in an incident involving mail, before the investigation has worked out exactly what was deleted.
Holds have costs worth knowing. They keep content that might otherwise be removed under the organization's normal retention rules, and they count against the mailbox's recoverable items quota. They also need to be removed deliberately when the case closes, and Module 4 covers recording when and why each one was placed so it does not outlive its purpose.
The Evidence Inventory
What exists for this incident, before reading any of itBefore collecting anything, it helps to know what there is to collect. An evidence inventory lists, for the people and the time window in scope, which sources hold records and how many. It is quick to build, it decides the order of collection, and it is the first thing a second investigator needs when they join the case.
For the compromised finance account in the course dataset, one query produces it across the Entra ID and audit sources:
let user = "c.richardson@ne.com";
let start = datetime(2026-02-27T00:00:00Z);
let stop = datetime(2026-03-05T00:00:00Z);
union withsource = Source
(SigninLogs | where UserPrincipalName == user),
(AADNonInteractiveUserSignInLogs | where UserPrincipalName == user),
(OfficeActivity | where UserId == user),
(AuditLogs | where tostring(InitiatedBy) contains user
or tostring(TargetResources) contains user)
| where TimeGenerated between (start .. stop)
| summarize Records = count(), Earliest = min(TimeGenerated),
Latest = max(TimeGenerated) by Source
Four sources return records for the window: 128 mailbox and file records in OfficeActivity, 53 non-interactive and 35 interactive sign-ins, and 5 directory audit records. The audit records are the smallest set and among the most important. Reading them shows that within sixteen minutes of the attacker's first sign-in at 18:47 on 27 February, the account consented to an application at 18:55, registered new security information at 18:58, had its user object updated at 19:00 and was added to a group at 19:03.
Email evidence lives in Defender XDR's tables rather than Sentinel's, and those tables use a column called Timestamp rather than TimeGenerated, which is why they are queried separately:
EmailEvents
| where RecipientEmailAddress == "c.richardson@ne.com"
| where SenderFromAddress == "invoices@northgateeng-accounts.com"
| project Timestamp, SenderFromAddress, Subject, DeliveryAction, NetworkMessageId
It returns one message, delivered at 18:45 from a domain made to resemble the organization's own, with a subject about an outstanding invoice. Its NetworkMessageId links to the click record in UrlClickEvents at 18:46. The inventory now runs from the email at 18:45 to the last audit change at 19:03, and the email tables are the ones whose thirty days of hunting retention expire soonest, so they are collected first.
The inventory also shows something the investigation has not yet looked at. The 53 non-interactive sign-ins in the window are the background token refreshes, and some of them will belong to the attacker's session rather than the user's devices. They are the largest single set of identity records for the incident and the one most often skipped, because they are not shown by default in the sign-in pages. Lesson 0.5 explains why they matter.
An inventory is not a finding, and it is worth saying so in the case notes. It says where records exist and how many, not what they mean. Its value is that every later decision about what to collect, read and preserve can be traced back to it, and that nothing obviously relevant was missed simply because nobody thought to look in that table.
Exporting: Copies You Control
What to keep with every exportCollection in a tenant means exporting. Every source used in this course can export records: query results from Sentinel and advanced hunting, audit search results from Purview, sign-in and audit logs from Entra ID, message traces from Exchange. The export is the evidence; the original stays with Microsoft and keeps ageing.
Four habits make an export trustworthy. Export more than the question needs, with the time window widened on both sides, because the next question will need the records just outside the first one's window. Keep the query that produced it, verbatim, in a file next to the export. Keep times in UTC, as the source holds them, and never reformat timestamps in a spreadsheet. And export in a format that preserves the data, such as CSV or JSON, rather than a screenshot or a PDF of a portal page.
For the unified audit log the export is a PowerShell search written straight to a file:
PS C:\> $r = Search-UnifiedAuditLog -StartDate 2026-02-26 -EndDate 2026-03-06 `
-UserIds c.richardson@ne.com -ResultSize 5000 -SessionCommand ReturnLargeSet
PS C:\> $r | Sort-Object Identity -Unique |
Export-Csv .\ual-c.richardson-2026-02-26_2026-03-06.csv -NoTypeInformation
PS C:\> ($r | Sort-Object Identity -Unique).Count
The search asks for up to 5,000 records rather than accepting the default, removes the duplicates the audit search is known to return, and writes the result to a file whose name carries the user and the window. The last line prints the deduplicated count, which is recorded with the file so anyone repeating the search can compare. Module 3 explains the search behaviors behind each of those choices.
Entra ID's own logs export the same way. The sign-in and audit pages in the admin center download the filtered view as CSV or JSON, which is convenient for a single user and a short window but limited in volume. For larger collections, the same records are pulled through Microsoft Graph or, where they are routed, queried from the workspace and exported from there. Whichever route is used, the export carries the filter that produced it, written down beside the file.
Entra Admin Center
Entra ID › Monitoring & health › Sign-in logs › Download
Filter to the user and window first, then download as CSV or JSON. The file contains every field of each record, whatever columns were showing. Browser downloads work well up to about 100,000 sign-in records or 250,000 audit records.
The file name is not a detail. Six months later, export.csv, export (1).csv and export-final.csv are three files nobody can tell apart. A name that carries the subject, the source and the window answers the first question anyone will ask about it without opening it.
What a Hash Proves
Integrity since that moment, nothing moreA cryptographic hash is a short fixed-length value computed from a file's contents. Change a single byte of the file and the hash changes completely, and it is not practical to construct a different file with the same hash. Recording a file's hash at collection lets anyone later confirm the file is byte-for-byte the one that was collected.
PS C:\> Get-FileHash .\ual-c.richardson-2026-02-26_2026-03-06.csv -Algorithm SHA256 |
Format-List
Algorithm : SHA256
Hash : 9F2C4A1E7B0D3E8A6C5F14B2D9E07A3C8B1F6D2E4A9C0B7E5D3F1A8C6E2B4D07
Path : C:\case\ual-c.richardson-2026-02-26_2026-03-06.csv
That is exactly what a hash proves, and it is worth being precise about what it does not prove. It does not prove the export was complete: a search that returned 100 records when 5,000 existed produces a perfectly hashable file. It does not prove the query was the right one, or that the source recorded the activity correctly. It proves only that the file has not changed since the hash was taken.
So the hash is taken immediately after export, before the file is opened, sorted or filtered by anyone. SHA-256 is the algorithm to use: older algorithms such as MD5 and SHA-1 still detect accidental change, but they are no longer trusted against deliberate tampering, and a challenge to the evidence will raise that point. A hash computed after somebody opened the CSV in a spreadsheet and saved it proves the integrity of the edited file, not of what the tenant returned.
Record the hash where it cannot be quietly changed along with the file: in the custody record, in the case ticket, or in a message to the incident lead. A hash stored only in a text file beside the export proves nothing if both can be edited together.
The working copy is a separate file. Analysts sort, filter and annotate a copy, and the hashed original stays untouched in the case folder. When a finding is challenged, the original and its hash show what the tenant returned, and the working copy shows what was done with it.
Custody Without the Original
Recording what happened to each copyClassic chain of custody tracks a physical item from seizure to court: who held it, when, and what was done to it. In a tenant there is no physical item and the original never leaves Microsoft. Custody still matters, but what it tracks is the copy and the process that produced it.
Custody in a tenant follows the copy, not an original. Each step writes one part of the custody record.
A custody record built from those steps is short, and grows by one line each time the copy moves:
Custody record, item E-004
Prepared exampleAccess log
- 2026-03-05 10:15 UTC: working copy made by the analyst; original untouched
- 2026-03-06 14:00 UTC: hash re-checked before transfer; matched
- 2026-03-06 14:05 UTC: original sent to outside counsel by secure transfer
The account that ran the collection matters more than it seems. Collection with a privileged administrator account is itself an auditable action in the tenant, and the investigator's own searches appear in the audit log. This cuts both ways. The audit log will show every search the investigation ran, which is useful when someone later asks what was looked at and when. It also means an attacker with access to the audit log can see that an investigation has started. Using a named, dedicated investigation account makes those entries easy to recognize and to exclude from the attacker's timeline, and it keeps the investigator's actions separate from the administrators who may be under scrutiny themselves.
Where the evidence is kept matters too. Exports of a compromised tenant's mail and audit records are sensitive, and they belong somewhere with restricted access that is not inside the compromised tenant itself. An attacker who still holds an administrator's session can read a case folder in that administrator's OneDrive as easily as anything else.
What Module 4 Builds On It
From principles to a collection planModule 4, Evidence Collection, makes each of these ideas a procedure. It covers what cannot be imaged and what replaces it, preserving before collecting, the eDiscovery tooling that replaced three older tools, the index that quietly omits some content, exporting the audit record, capturing artifacts before removal, what a hash proves, custody without custody, what the collection lets you notify on, and the package somebody else reads.
Module 4 also covers the point at which collection stops. An investigation can always collect more, and the cost of collecting everything is time the incident may not have. The answer is to collect to the questions: what the scope statement, the containment decision and the notification will rest on, plus the margin around each. The inventory is what makes that judgment possible, because it shows what exists before any time is spent collecting it.
The habit to start now is the inventory. Before any incident query that matters, list what exists for the people and window in scope, collect the sources closest to expiry first, and capture every artifact containment is about to remove. A short query gives the order of collection by showing which sources reach furthest back:
union withsource = Source
(SigninLogs | where UserPrincipalName == "c.richardson@ne.com"),
(OfficeActivity | where UserId == "c.richardson@ne.com")
| summarize Oldest = min(TimeGenerated) by Source
| order by Oldest asc
In the course dataset both sources reach back to 13 February, because the workspace keeps everything for the same period, and the mailbox records happen to start a little earlier. In a tenant relying on default retention the picture changes: the Entra ID sign-in log keeps thirty days against the unified audit log's 180, so the sign-in log's oldest record is the one about to disappear. Whatever the tenant, the source at the top of that list is collected first.
Practice
Would this collection hold up? prepared evidenceThe prepared evidence below is a colleague's collection log from the first morning of an incident. Decide which items will hold up as evidence, which will not, and what should have been done differently.
The second path is to collect properly yourself, from the course dataset or your own tenant, and produce the custody record alongside the files.
- Run the inventory query in section four and decide the order of collection from it.
- Export the directory audit records and the mailbox records for the window, saving each query beside its export.
- Hash each file with
Get-FileHash -Algorithm SHA256before opening it, and record the hash and the record count. - Write the custody record with the four rows from section seven for every file.
Records become evidence through provenance: a known source, a recorded query, a time, a collector and proof the copy has not changed. Preservation comes before collection, because expiry, deletion and the response itself all destroy evidence. Holds keep what gets deleted from the moment they are placed, an inventory sets the order of collection, and a hash proves integrity from the moment it was taken and nothing more.
The next lesson goes inside the sign-in itself, to the tokens and sessions that most modern attacks on Microsoft 365 steal.
Resources
Microsoft revises these pages; where a page and this lesson disagree, the page is newer.