When managing Microsoft 365 environments, administrators often need to audit or fetch users' emails for troubleshooting, compliance, or reporting. The Get-MgUserMessage cmdlet from Microsoft Graph PowerShell makes this task seamless by letting you retrieve email messages directly from users’ mailboxes.
In this guide, we'll explore why and how to use this cmdlet, walk through practical examples, and highlight real-world use cases.
Get-MgUserMessage is a Microsoft Graph PowerShell cmdlet used to fetch messages from a specific user’s mailbox. Whether you want to view the latest emails, retrieve specific messages, or extract only certain fields, this cmdlet has you covered.
Here are a few reasons admins prefer this cmdlet:
Get-MgUserMessage -UserId [-MessageId ] [-Top ] [-Filter ] [-Search ] [-Property ] [-All] []
UserId is the only mandatory parameter. It refers to the user's UPN (email address) or user ID.
Get-MgUserMessage -UserId "john.doe@contoso.com"
This retrieves the first page of messages from the user's inbox.
Get-MgUserMessage -UserId "john.doe@contoso.com" -MessageId "AAMkAGI2T..."
Useful for retrieving the full message details using its unique identifier.
Extracting subject, sender, received date, and recipient info in a grid view:
$User = "samadmin@7xh7fj.onmicrosoft.com"
Get-MgUserMessage -All -UserId "$User" |
Select-Object Subject, InternetMessageId, ReceivedDateTime,
@{Name = "Sender"; Expression = { $_.Sender.EmailAddress.Address }},
@{Name = "Recipients"; Expression = { $_.ToRecipients.EmailAddress.Address -join ' ' }} |
Out-GridView
Perfect for exporting summarized message data.
Get-MgUserMessage -UserId "john.doe@contoso.com" -Filter "contains(subject,'Project Update')"
Fetches only the emails with “Project Update” in the subject line.
Get-MgUserMessage -UserId "john.doe@contoso.com" -Search "Project Update"
Searches across multiple properties (subject, body, etc.) for the phrase "Project Update".
Get-MgUserMessage -UserId "john.doe@contoso.com" -Top 10
Fetches the 10 most recent messages.
Get-MgUserMessage is a powerful tool that brings transparency and control to Microsoft 365 email management. With a few lines of PowerShell, you can pull critical email data, filter through messages, and extract meaningful insights from user mailboxes.
Whether you're auditing, troubleshooting, or automating reporting tasks, this cmdlet deserves a spot in your admin toolkit.
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex