Managing mailbox rules is crucial for automating email workflows, and Microsoft Graph PowerShell provides a simple way to access these rules -- using Get-MgUserMailFolderMessageRule cmdlet. In this guide, you'll learn how to fetch, view, and filter message rules effectively.
Get-MgUserMailFolderMessageRule is a Microsoft Graph PowerShell cmdlet used to retrieve the message rules (also known as inbox rules) associated with a specific mail folder in a user's Microsoft 365 mailbox.
Each rule defines an action for incoming messages, such as moving emails to a folder, forwarding emails, or marking them as read.
Get-MgUserMailFolderMessageRule -UserId <String> -MailFolderId <String> [-MessageRuleId <String>] [-ExpandProperty <String[]>] [-Property <String[]>]
Parameters:
Note: To fetch MailFolder IDs, use the Get-MgUserMessageFolder cmdlet.
Get-MgUserMailFolderMessageRule -UserId "user@example.com" -MailFolderId "AAMkAGI2TgAAA="
This command retrieves all message rules in the specified mail folder for the user.
Get-MgUserMailFolderMessageRule -UserId "user@example.com" -MailFolderId "AAMkAGI2TgAAA=" -MessageRuleId "AQMkAGI2TgAAA="
This fetches a specific message rule based on its MessageRuleId.
Get-MgUserMailFolderMessageRule -UserId "user@example.com" -MailFolderId "AAMkAGI2TgAAA=" | Where-Object { $_.isEnabled -eq $true }
This retrieves only the rules that are currently active (enabled).
Note: Use Get-MgUserMessageFolder cmdlet to fetch the MailFolder IDs before using Get-MgUserMailFolderMessageRule.
The Get-MgUserMailFolderMessageRule cmdlet offers a straightforward method to retrieve and audit message rules from a user's mailbox. Whether you're troubleshooting email delivery, automating audits, or managing mailbox workflows, this cmdlet gives you full visibility into how incoming messages are handled.
Combine it with other Microsoft Graph PowerShell cmdlets to create powerful scripts for email governance in your Microsoft 365 environment!
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