Skip to content

Add Get-AllMessageTraceResults script and documentation#2527

Merged
dpaulson45 merged 5 commits into
mainfrom
Nickul-AddGetAllMessageTraceScript
Apr 7, 2026
Merged

Add Get-AllMessageTraceResults script and documentation#2527
dpaulson45 merged 5 commits into
mainfrom
Nickul-AddGetAllMessageTraceScript

Conversation

@Nickul-MSFT
Copy link
Copy Markdown
Contributor

Summary

Adds a standalone reusable function that wraps Get-MessageTraceV2 with automatic pagination support. This makes it easy to retrieve all matching message trace results from Exchange Online without manually
handling the pagination logic.

Changes

  • Transport/Get-AllMessageTraceResults.ps1 — New script containing the Get-AllMessageTraceResults function
  • docs/Transport/Get-AllMessageTraceResults.md — Documentation landing page with parameter descriptions and usage examples

Details

  • Exposes all Get-MessageTraceV2 parameters (SenderAddress, RecipientAddress, Status, Subject, FromIP, ToIP, MessageId, MessageTraceId, SubjectFilterType)
  • Automatically pages through results using the WarningVariable continuation pattern
  • Uses List[object] instead of array concatenation (+=) for better performance at scale
  • Includes a configurable timeout (-TimeoutMinutes) to prevent runaway queries
  • Adds a -PageSize parameter (mapped to -ResultSize) to control results per page, defaulting to the maximum of 5000

@Nickul-MSFT Nickul-MSFT requested a review from a team as a code owner April 3, 2026 17:35
Copilot AI review requested due to automatic review settings April 3, 2026 17:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a reusable PowerShell helper to fetch all Exchange Online message trace results by wrapping Get-MessageTraceV2 and automatically handling pagination, plus accompanying documentation.

Changes:

  • Introduces Get-AllMessageTraceResults with automatic pagination and a timeout guard.
  • Adds docs describing parameters and usage examples.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
Transport/Get-AllMessageTraceResults.ps1 New function wrapping Get-MessageTraceV2 and paging through all results.
docs/Transport/Get-AllMessageTraceResults.md New documentation page for the script/function and its parameters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
@Nickul-MSFT Nickul-MSFT force-pushed the Nickul-AddGetAllMessageTraceScript branch 3 times, most recently from 344fb99 to 7ff4275 Compare April 3, 2026 18:32
Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
Comment thread Transport/Get-AllMessageTraceResults.ps1 Outdated
Nickul-MSFT and others added 2 commits April 3, 2026 16:14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ected warnings

- Use moreAvailable[-1] instead of joining all warnings
- Add warning message when pagination fails with unexpected warning
- Include last command in warning for debugging

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Nickul-MSFT Nickul-MSFT force-pushed the Nickul-AddGetAllMessageTraceScript branch from 0e61149 to fecae41 Compare April 3, 2026 21:14
Nickul-MSFT and others added 2 commits April 3, 2026 16:59
…voke-Command

- Use StartingRecipientAddress and EndDate from last result for pagination
- Remove warning message parsing and dynamic scriptblock execution
- Move timeout check inside loop to only warn when data is actually truncated

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace 3>$null with 3>&1 stream redirection to capture warnings from
  Get-MessageTraceV2, then filter WarningRecord objects and surface them
  via Write-Verbose with page context
- Update doc description to clarify this is an Exchange Online wrapper
  requiring an active EXO PowerShell session
- Remove dot-sourcing from doc examples since the script is no longer
  a function

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dpaulson45
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Add the missing navigation entry for Get-AllMessageTraceResults under
the Transport section so the doc page appears on the site.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dpaulson45
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dpaulson45 dpaulson45 self-requested a review April 7, 2026 18:07
@dpaulson45 dpaulson45 merged commit a0930bf into main Apr 7, 2026
7 checks passed
@dpaulson45 dpaulson45 deleted the Nickul-AddGetAllMessageTraceScript branch April 7, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants