PowerShell - Office 365 Create Rule for Existing Emails
PowerShell - Office 365 Create Rule for Existing Emails
Summary
This Wiki is based on TechNet Form Post
Refer this Post Link
Background
- OP requested for moving emails from INBOX to folders.
- Exchange environment is on cloud.
Solution
NOPE!!! It's not possible Refer this Exchange Forum Post for more information It's not possible to achieve this using PowerShell. However some third party tools may do this by consuming EWS and I haven't tried any. Let's see the method to create and enable rule in Office 365 Exchange
Connect to Exchange Online
Import-Module MSOnline $O365Cred = Get-Credential 'Admin@Domain.onmicrosoft.com' $O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell ` -Credential $O365Cred -Authentication Basic -AllowRedirection Import-PSSession $O365Session Connect-MsolService –Credential $O365Cred |
Explore Command
Get-Command -Name '*Inbox*' |
Create Rule
New-InboxRule -Name Test -Mailbox 'MailBoxID' -From 'SomeMailID' -MoveToFolder 'MailBox:\Test' -Verbose |
Enable Rule
Enable-InboxRule -Mailbox 'MailBoxID' -Identity 'RuleID' -Verbose |
Explore Parameters
Help New-InboxRule -Parameter Name Help New-InboxRule -Parameter MoveToFolder Help Enable-InboxRule -Parameter RuleID |