March 31, 2014

Outlook 2010 - inbox rules

How to get list of Inbox rules using PowerShell on local workstation?

#Requires -version 2.0
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


Source: http://blogs.technet.com/b/heyscriptingguy/archive/2009/12/15/hey-scripting-guy-december-15-2009.aspx

No comments:

Post a Comment