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
Christian HansUndecided... Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Todd NelsonSystems EngineerCommented:
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

0
Christian HansUndecided... Author Commented:
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...
0
Christian HansUndecided... Author Commented:
Results = blank (no output)
0
Vasil Michev (MVP)Commented:
You are not getting any results because you are not using the pipeline correctly. The Get-InboxRule cmdlet uses the -Mailbox parameter to designate the mailbox object, and the -Identity parameter to designate the actual rule. In your case, you are passing the Identity. It doesnt matter anyway, as the -Mailbox parameter does not accept pipeline input.

In other words, use this:

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

Open in new window


not this

Get-Mailbox -ResultSize unlimited | Get-InboxRule -ErrorAction:SilentlyContinue 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Todd NelsonSystems EngineerCommented:
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

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.