Link to home
Start Free TrialLog in
Avatar of Christian Hans
Christian HansFlag for United States of America

asked on

Powershell Command To Display All User Mailbox InboxRules

Trying to run a Powershell Command To Display All User Mailbox InboxRules by running;  

Get-Mailbox -ResultSize unlimited | Get-InboxRule -ErrorAction:SilentlyContinue | Select MailboxOwnerID, name, from, redirectto, ForwardTo | Export-Csv c:\output\InboxRules_Forwards.csv -NoTypeInformation

...exports no information at all.

How can I run this via powershell to export ALL mailbox rules,

fields required/desired:

Enabled,Name,Priority,From,SentTo,CopyToFolder,DeleteMessage,ForwardTo,MarkAsRead,MoveToFolder,RedirectTo,SendTextMessageNotificationTo,MailboxOwnerId
Avatar of Todd Nelson
Todd Nelson
Flag of United States of America image

If it "exports no information at all" then there are probably no inbox rules set.

Also, if there are on premises and EXO mailboxes, you will need get info from EMS and also connected to EXO via PowerShell.

This command should work for both environments.  Just change the output location if running on the same machine.

Get-Mailbox -ResultSize Unlimited | Get-InboxRule -ErrorAction:SilentlyContinue | Select Enabled,Name,Priority,From,SentTo,CopyToFolder,DeleteMessage,ForwardTo,MarkAsRead,MoveToFolder,RedirectTo,@{Expression={$_.SendTextMessageNotificationTo};Label="SendTextMessageNotificationTo"},MailboxOwnerId | Export-Csv C:\Output\InboxRules_Forwards.csv -NoTypeInformation

Open in new window

Avatar of Christian Hans

ASKER

Thanks Todd, running your suggestion now.

I have confirmed that we do have mailboxes with rules, plenty of them... which is why its so strange that the results didn't pull anything back.

Get-InboxRule -Mailbox First.Last@contoso.com pulls back rules...
Results = blank (no output)
ASKER CERTIFIED SOLUTION
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Huh?  I got output.

What Vasil provides will not work on premises because you have to pass a name or alias--not an email address.

Get-Mailbox -ResultSize Unlimited | % { Get-InboxRule -Mailbox $_.PrimarySmtpAddress }

Open in new window



But the following does (for both on premises Exchange and EXO), just like the previous command I provided (in on premises Exchange)...

Get-Mailbox -ResultSize Unlimited | % { Get-InboxRule -Mailbox $_.Alias }

Open in new window


And so does this...

Get-Mailbox -ResultSize Unlimited | % { Get-InboxRule -Mailbox $_.Name }

Open in new window



The following will output to a CSV file...

Get-Mailbox -ResultSize Unlimited | % { Get-InboxRule -Mailbox $_.Alias | Select Enabled,Name,Priority,From,SentTo,CopyToFolder,DeleteMessage,ForwardTo,MarkAsRead,MoveToFolder,RedirectTo,@{Expression={$_.SendTextMessageNotificationTo};Label="SendTextMessageNotificationTo"},MailboxOwnerId } | Export-Csv C:\Output\InboxRules_Forwards.csv -NoTypeInformation

Open in new window