Link to home
Start Free TrialLog in
Avatar of thebrepp
thebreppFlag for United States of America

asked on

Check for Outlook 2010 Rule Error with Powershell

Local/Desktop Outlook 2010 (not Exchange) has rule that occasionally errors out. Is there a Powershell command that can be used to see if rule is in error state and ideally reset it.  Currently to reset I go into rule edit and Next through it and that clears the error.  I would like to at least be able to have Powershell script send an email to another user for this :unmanned" Outlook mailbox.
Avatar of Christ Harold
Christ Harold
Flag of Netherlands image

Hi,
If you want to use the PowerShell command to see the rules of outlook then read this
https://technet.microsoft.com/en-us/library/dd351062(v=exchg.160).aspx

Hope this will help you up to some extent
Christ
Avatar of Qlemo
You can access such local settings only by Office Automation, which is the same code you use in VBA inside of Office.
You cannot set up something running and correcting automatically. However,  it should be feasible to run that manually. I would do that in Outlook VBA, adding a shortcut in the Quick Access Toolbar.
Avatar of thebrepp

ASKER

The two wrinkles are comments so far which I thank you for are that this is not an Exchange based setup which kills use of that cmdlet and the other is that this mail box is parked on a file server and only used to capture emails and route to some folders with some processing done via vba.  In other words there is no user watching this as the destination  folders are shared via an app for that.  I'm trying to setup a powershell process to at least send an email notice when it sees the rule is in an error state which happens randomly every two week or so.  Other users are trying to avoid going to the server Outlook account.  The following powershell routine gets enabled info on rules but not if rule is errors out (I think).  I have to test it once rule errors out which has not happened yet for a week.
#ListOutLookRules.ps1
Add-Type -AssemblyName microsoft.office.interop.outlook
$olFolders = “Microsoft.Office.Interop.Outlook.OlDefaultFolders” -as [type]
$outlook = New-Object -ComObject outlook.application
$namespace  = $Outlook.GetNameSpace(“mapi”)
$folder = $namespace.getDefaultFolder($olFolders::olFolderInbox)
$rules = $outlook.session.DefaultStore.GetRules()
$rules |
Sort-Object -Property ExecutionOrder |
Format-Table -Property Name, ExecutionOrder, Enabled, isLocalRule -AutoSize
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany 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
Thanks Qlemo - I was afraid of that.  I'm going to attempt a vba routine that the 2 key users can park on their pc's outlook or access to run periodically and check if rule is in error condition.  I'm thinking if I can do that, then your rule save routine should do it.  I'll let you know.  thanks
If I get you right you can run a scheduled task checking for the inbox, and if it contains messages perform the Save. That removes the need for any manual intervention.
I decided to come at this from a different angle.  The rule checks on sender and subject line and if correct moves to another Outlook folder and saves any attachments to a folder on the server via vba script called by the rule. It also does some parsing out of the subject line for a rename of that attachment.  When the rule fails for no apparent reason nothing happens and the email remains in the Inbox.  
I'm going to create powershell script to check for any of those emails in the Inbox which indicates the rule as failed.  The use your lines to re-save that rule.  Pause for 15 seconds and then recheck.  If that still indicates emails in that Inbox - send key user an email to intervene.
I'll beef up the vba script too to collect any errors it may encounter.