Get All Users Outlook/Inbox Rules in Office 365

Description: This article will show you how to utilize PowerShell to get Inbox/Outlook rules for all mailboxes in your organization.

The PowerShell cmdlet to view inbox rules is Get-InboxRule. First we want to grab all mailboxes in the organization and store the UserPrincipalName in a variable.  Here we are storing it in a variable called “Users”

Then for each user we are going to get the InboxRule and select several attributes:

  • MailboxOwnerID
  • Name
  • Description
  • Enabled
  • RedirectTo
  • MoveToFolder
  • ForwardTo

The entire list of attributes we can grab per mailbox is:

  • Enabled
  • Identity
  • InError
  • ErrorType
  • Name
  • Priority
  • RuleIdentity
  • SupportedByTask
  • Legacy
  • BodyContainsWords
  • ExceptIfBodyContainsWords
  • FlaggedForAction
  • ExceptIfFlaggedForAction
  • FromAddressContainsWords
  • ExceptIfFromAddressContainsWords
  • From
  • ExceptIfFrom
  • HasAttachment
  • ExceptIfHasAttachment
  • HasClassification
  • ExceptIfHasClassification
  • HeaderContainsWords
  • ExceptIfHeaderContainsWords
  • FromSubscription
  • ExceptIfFromSubscription
  • MessageTypeMatches
  • ExceptIfMessageTypeMatches
  • MyNameInCcBox
  • ExceptIfMyNameInCcBox
  • MyNameInToBox
  • ExceptIfMyNameInToBox
  • MyNameInToOrCcBox
  • ExceptIfMyNameInToOrCcBox
  • MyNameNotInToBox
  • ExceptIfMyNameNotInToBox
  • ReceivedAfterDate
  • ExceptIfReceivedAfterDate
  • ReceivedBeforeDate
  • ExceptIfReceivedBeforeDate
  • RecipientAddressContainsWords
  • ExceptIfRecipientAddressContainsWords
  • SentOnlyToMe
  • ExceptIfSentOnlyToMe
  • SentTo
  • ExceptIfSentTo
  • SubjectContainsWords
  • ExceptIfSubjectContainsWords
  • SubjectOrBodyContainsWords
  • ExceptIfSubjectOrBodyContainsWords
  • WithImportance
  • ExceptIfWithImportance
  • WithinSizeRangeMaximum
  • ExceptIfWithinSizeRangeMaximum
  • WithinSizeRangeMinimum
  • ExceptIfWithinSizeRangeMinimum
  • WithSensitivity
  • ExceptIfWithSensitivity
  • ApplyCategory
  • ApplySystemCategory
  • CopyToFolder
  • DeleteMessage
  • DeleteSystemCategory
  • ForwardAsAttachmentTo
  • ForwardTo
  • MarkAsRead
  • MarkImportance
  • MoveToFolder
  • PinMessage
  • RedirectTo
  • SendTextMessageNotificationTo
  • StopProcessingRules
  • MailboxOwnerId
  • IsValid
  • ObjectState
  • RunspaceId
  • Description

Finally, we are going to export the information to a CSV. The -Append parameter is necessary so it doesn’t overwrite the csv file as it moves onto the next mailbox.

CSV: Below is a csv sample file

ScriptBlock: 

NOTE: To run in Office 365 you must first connect to Office 365

 

 

Comments

  1. Is there a way to then import these rules into Office 365?

  2. Is there a way to then import these rules into Office 365?

Leave a Comment