This post follows on a little from a previous post where i was talking about invalid delegates. One thing the current EWS Rule operations in Exchange 2010 and also the Get-InboxRule cmdlets can't do is that both of these wont display any information about the delegate forward rule if its been configured. Now you can tell using the delegate operation if a forward rule has been configured for a user but this still doesn't read the rule object directly. You could question why you would want to do this if that's the case and the reason is usually when your trying to diagnose why somebody maybe geting a bounce message when meeting messages are being forwarded to an invalid mailbox user (eg a deleted delegate).
If you want to find what delegates the delegate rule is forwarding to you need to read these directly from the rule object. On Exchange 2010 you can access Folder Associated Items (FAI) and the Delegate rule object. In EWS to find this you can create a searchfilter and look for the FAI item where the PR_RuleMsgProvider_W property is set to "Schedule+ EMS Interface". Once there the address that a delegate is forwarded to are stored in the PidTagRuleMsgActions property which is documented in Rules protocol document http://msdn.microsoft.com/en-us/library/cc463893%28v=EXCHG.80%29.aspx . Parsing this property however is not trivial basically this property is a stream of serialized MAPI properties so one property that stores other properties such as PR_DisplayName and PR_EMAIL_ADDRESS_W. Fortunately i had a bit of experience and code from the FTS Stream parser i wrote and with some simple adaption this code can be more or less plugged in and returns all the properties and value parsed correctly. For the purpose of reading the delegates a forwarding rule is forwarding to PR_EMAIL_ADDRESS_W is the important property.
So to make this usable from Powershell I've created some cmdlets that first allows you to read the raw actions property on the delegate rule. Display any of these rules that are invalid it does this by using a EWS getdelegate operation and then comparing the valid entries retrieved with the delegate rules that exist. Then there is a unsupported remove cmdlet although the method I've used in not that bad basically what the remove does is if it finds one valid delegate in the delegate rule it forces an update of this delegate rule using an update delegate operation which will cause the delegate rule to be updated which will remove the invalid entry (as long as you have cleaned up the invalid delegates in Outlook or the other Remove-MessageOps.MailboxDelegatesInvalid.Unsupported cmdlet).
Get-MessageOps.MailboxDelegateForwardingRules: This cmdlet retrieves the MailboxDelegate Forwarding rules by finding the rules object in the associated folders collection of the Inbox and then parsing the actions MAPI property on this object. Note because of the limitation in EWS in 2007 this cmdlet will only work on Exchange 2010.
Example: Get-MessageOps.MailboxDelegateForwardingRules –p $ewsprofile –identity firstname.lastname@example.org
Get-MessageOps.MailboxDelegateInvalidForwardingRules: This cmdlet retrieves the MailboxDelegate Forwarding rules by finding the rules object in the associated folders collection of the Inbox and then parsing the actions MAPI property on this object. It then compares the entries contained in the forwarding rule to check if there is a valid delegate for this entry by using a getdelegates operation. Any users that don’t have a valid delegate entry is returned as invalid.
Example: Remove-MailboxDelegateInvalidForwardingRules –p $ewsprofile –identity email@example.com
Remove-MessageOps.MailboxDelegateInvalidForwardingRules.Unsupported: This cmdlet retrieves the MailboxDelegate Forwarding rules by finding the rules object in the associated folders collection of the Inbox and then parsing the actions MAPI property on this object. It then compares the entries contained in the forwarding rule to check if there is a valid delegate for this entry by using a getdelegates operation. If an invalid entry is found depending on the number of delegate entries the following action are taken.
· If other valid entries are found a update delegate operation is performed on one these entries which should make the sever side process remove the invalid entry when the forward rule is updated.
· If no other valid entries are found the rule object is deleted.
Example: Remove-MessageOps.MailboxDelegateInvalidForwardingRules.Unsupported –p $ewsprofile –identity firstname.lastname@example.org
To use these cmdlets you need to download the following module http://www.messageops.com/downloads/MessageOps-Exchange-Module.zip