Jan 10 2017

Removing mail with the same subject from the Exchange Queues

Sometimes you need to remove thousands of e-mails in your Hub Transport server queues. We see this every now and then with mail storms from an application that went off the rails or maybe with 2 mailboxes sending each other auto replies causing a mail loop.

There’s a few ways to stop the mail storm before removing the mail items in your Exchange queues but that is not the scope for this article. If you are ever in the situation of thousands of mails queued on all your Hub Transport servers then the below cmdlet should help you to quickly remove those mails from the queue. (Obviously do this with mails that are not classified as normal business or valid mail i.e. auto response loops)

  1. Get-TransportServer HubTransportServerName| Get-Queue | Get-Message -ResultSize unlimited | where {$_.Subject -eq “Paste the subject you need removed here.”} | Remove-Message -WithNDR $False

a better way might be #2 below if you don’t want to confirm deletion and have to run it across all your Hub Transport Servers: (Thanks to Clinton Hardenberg for the updated cmdlet)

2. Get-TransportServer HTServer0* | Get-Queue |where {$_.MessageCount -gt 25} | Get-Message -ResultSize unlimited | Where {$_.Subject -eq “Paste the subject you need removed here.”} |            Remove-Message -WithNDR $False -Confirm:$false

The 2nd cmdlet will use the 1st part of your server names i.e. if you have HT01, HT02 and HT03 then use HT0* to remove the mail across all your HT servers. The -WithNDR $False will delete the mail and not send an NDR which is important in this case as you will just increase the number of mails when it’s set to $True. -Confirm $False negates the need to select “A” and confirm that you want to remove the mail items from the queues.

There are other parameters you can use to define which items you want to remove but in the above examples we use the Subject as we deal mostly with mail storms by Subject as they are usually

 


Nov 14 2016

Unable to access or move a mailbox receiving error the mailbox is disabled when it’s not

If you ever try to move a mailbox and you receive an error that the mailbox is disabled but you have checked and the mailbox is not disabled then try the following:
(other errors we received was trying to access the mailbox using Outlook Web App and stating it’s disabled or from Outlook stating you need to connect to Exchange)

  • Verify that the mailbox is indeed not disabled. If not proceed to the next steps
  • Open Exchange Management Shell and run: Set-CASMailbox -Identity mailboxSMTPAddress@domain.com -MAPIEnabled $False
  • Wait for replication
  • Run: Get-CASMailbox mailboxSMTPAddress@domain.com (check that it shows MAPI Enabled is false)
  • If MAPI Enabled is false run: Set-CASMailbox -Identity mailboxSMTPAddress@domain.com -MAPIEnabled $True
  • Wait for replication
  • Run: Get-CASMailbox mailboxSMTPAddress@domain.com (check that it shows MAPI Enabled is true)
  • Try an connect to the mailbox using Outlook, Outlook Web App or moving the mailbox.
  • If you still get an error try running: Clean-MailboxDatabase DatabaseNameWhereTheMailboxIsHomed (we actually had to run this for one of the mailboxes giving us issues)

This should sort out the issue for you.


Nov 14 2016

VB.Net application unable to connect to some Exchange 2010 mailboxes

We had an interesting issue last week where a Visual Basic .Net application could connect to some mailboxes but could not connect to other mailboxes on Exchange 2010. The application uses MAPI to connect to the mailboxes.

We were however able to access the affected mailboxes using Outlook and with the MFCMAPI tool from the application server. We moved the affected mailboxes to other servers and databases but the application could still not connect to the affected mailboxes. We then added our CAS Array name and IP in the application server’s host file and checked the Exchange RCA logs.

We could not see any connections from the application server to the affected mailboxes but could see connections to the working mailboxes in the RCA logs.

The error from the application were as below but note that it was misleading as it stated it authenticated, connected but could not expand the mailbox store.

ProcessMails() LogonExchangeMailbox Success
———————————————————————————
Date Time : 2016-11-07 06:30:17
Error : Error in IMAPISession::OpenMsgStore: MAPI_E_FAILONEPROVIDER
ulVersion: 0
Error: The information store could not be opened.
Component: MAPI 1.0
ulLowLevelError: 0
ulContext: 649
Source : at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at MailReader.Form1.ProcessMails(String sToDoFolder, String sDuplicateToDoFolder, String sTiffFolder, String sDuplicateTiffFolder, String sExchangeServer, String sInboxUser, String sInboxName, Int32 maxItems, Int32 branchRef)

We then resolved the issue by doing the following:

  • Opened Exchange Management Shell
  • Ran this cmdlet against a working mailbox: get-mailbox mailboxSMTPaddress@domain.com |fl *legacy*
  • Made a note of the output
  • Ran the above cmdlet against a non working mailbox and compared the outputs.

The output of the working mailbox:

ServerLegacyDN : /o=yourdomain/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=MailboxServerName
LegacyExchangeDN : /o=yourdomain/ou=exchange administrative group (fydibohf23spdlt)/cn=recipients/cn=MailboxAlias

The output of the non working mailboxes:

ServerLegacyDN : /o=yourdomain/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=MialboxServerName
LegacyExchangeDN : /o=yourdomain/ou=SomeOU/cn=recipients/cn=MailboxAlias

The fix:

We then used AD Attribute Editor to change the LegacyExchangeDN on non working mailboxes (LegacyExchangeDN : /o=yourdomain/ou=SomeOU/cn=recipients/cn=MailboxAlias) to reflect the working mailboxes’ LegacyExchangeDN (LegacyExchangeDN : /o=yourdomain/ou=SomeOU/cn=recipients/cn=MailboxAlias)

Waited for replication and the application could once again access all the required mailboxes.


Sep 13 2016

Error due to mismatch of GUID: Recipient “NameOfRecipient” has mismatched Archive GUID

You receive the error “Recipient “NameOfRecipient” has mismatched Archive GUID” when you try and off board a mailbox from Exchange Online to on premises Exchange.

Follow the below steps o resolve the issue and migrate the mailbox back to the on premises Exchange environment:

  1. Logon to Exchange Online using Powershell.
  2. Run: get-mailbox user | fl *archiveguid*
  3. Make a note of the GUID
  4. Open Exchange Management Shell on premises
  5. Run: Get-RemoteMailbox User | fl *archiveguid*
  6. You should see that the GUID on prem is different to the GUID from Exchange Online
  7. To resolve, in Exchange Management Shell on prem run: Set-RemoteMailbox User -ArchiveGuid “GUID you got from Exchange Online”

The above should work without any issues but we had an issue where the mailbox in question was migrated from Exchange 2007, we want to migrate it back to an Exchange 2010 DAG and received the below error when trying to set the GUID as per step 7 above:

Property Archive GUID can’t be set on on this object because it requires the object to have version 0.10 (14.0.100.0) or later. The object’s current version is 0.1 (8.0.535.0)

To resolve the above error follow the below steps:

  1. Open Active Directory Users and Computers
  2. Make sure you choose view -> Advanced Features
  3. Browse to the User, right click on the user and choose Properties
  4. Click on the Attribute Editor Tab
  5. Look for MSExchVersion and open it
  6. We had to change the version to Exchange 2010 from 2007. Thus change the data to 44220983382016
  7. Click OK
  8. Wait for replication and run the Set-RemoteMailbox User -ArchiveGuid “GUID you got from Exchange Online” again from Exchange Management Shell on prem.
  9. Wait for replication
  10. Run get-mailbox User | fl *archiveguid* and make sure the GUID has now been changed to the GUID you found in Exchange Online
  11. Proceed to migrate the mailbox to on prem after the GUID has been set

The Exchange Version AD Attributes are:

Exchange 2010: 44220983382016

Exchange 2007: 4535486012416

We used the below 2 web articles / blogs which assisted us greatly. Please check out these articles as well as they were the sources used to resolve the above mentioned issues:

Paul Cunningham’s ExchangeServerPro.com website:

The Article which describes how to get the Archive GUID and set it on prem.

Technotip blog.

Here we found the attribute values for the Exchange versions.

 

 


Jan 8 2015

Unable to connect a disconnected mailbox – User not found error when trying to connect a mailbox to a user in Exchange

We’ve had a few instances where we need to disconnect a mailbox and reconnect it to a new user account for a user. This should be easy right? Well not always.

It’s happened more than once where we try to use the Exchange Management Console to connect the mailbox to the user account but Exchange can’t find the user account. Have a look in Active Directory and the account shows up. You then try to connect the mailbox to the user account using the Exchange Management Shell with the same results. user not found.

See below on how to get this issue resolved:

1. Open adsiedit.msc (start, run and type adsiedit.msc)
2. Search for the user
3. Open the properties for the user you need to connect the mailbox to
4. Search for the msExchRecipientTypeDetails property
5. For users, change the value from 1 to 0

Wait for replication and then reconnect the mailbox to the user account.

Thanks goes to our colleague Waleed for sharing this with us.

 


Nov 2 2014

Delivery has failed to these recipients or groups: Your message can’t be delivered because delivery to this address is restricted.

You probably have a lot of devices like printers, main frames and other non Microsoft systems sending mail to distribution groups inside your organisation.

If that’s the case and you receive an NDR as per below screenshot then you need to check authentication settings on the distribution group.

Capture

I recently had this problem where mail would not deliver to the recipients and after some testing we were able to generate the above NDR. The Distribution Group was set t only allow mail from authenticated users thus the reason for the mail delivery failure. The main frame is not able or setup to authenticate with Active Directory and could not send mail to that Distribution Group.

Follow the below steps to rectify the problem:

1. Open the Exchange Management Console
2. Click on “Recipient Configuration”
3. Click on “Distribution Group”
4. Find the Distribution Group that is not receiving the e-mail
5. Double click the Distribution Group or Right Click on it and choose Properties
6. Click on the “Mail Flow Settings” Tab
7. Double Click on “Message Delivery Restrictions”
8. Clear the check box next to “Require that all senders are authenticated” as per below screen shot. Now test mail flow from your system that is not able to authenticate.

Capture

 


Jul 7 2014

Deleting disconnected Mailboxes in Exchange 2007

Purging disconnected mailboxes in Exchange 2003 was quick and easy.

With Exchange 2007 you need to use the Exchange Management Shell to purge/delete the disconnected mailboxes. Below are some examples on how to delete disconnected mailboxes in Exchange 2007. Make sure that you need to delete the disconnected mailboxes as it’s easier to reconnect a disconnected mailbox if a user account and mailbox got deleted by accident.

Delete a specific disconnected mailbox:

1. Get-MailboxDatabase (this will show you  the database names)
2. Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid (view the user’s GUID here)
3.  Remove-Mailbox -Database Type Your Database Name Here -StoreMailboxIdentity Type the Users Mailbox GUID Here -confirm:$false

Delete all disconnected mailboxes from a specific database:

First create a variable $users as per point 1

1. $users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid
2. $users | ForEach { Remove-Mailbox -Database “Type Your Database Name Here” -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }

All the disconnected mailboxes in the specific database will now be deleted.


Jun 19 2014

Export mailbox sizes in Exchange 2010 using Exchange Management Shell

Thought I’d share two scripts today. I use both daily to export mailbox sizes to a csv file for reporting purposes.

These scripts will export the following:

User Display Name, Database where the mailbox is homed ,the mailbox’s  Total Item Size, Item Count in the mailbox and the Storage Limit Status

Export a report on mailbox sizes on a specific server:

Get-Mailbox –Server the server name –ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName, Database, TotalItemSize, ItemCount, StorageLimitStatus | Sort TotalItemSize, -Ascending | Export-CSV driveletter:\foldername\reportname.csv

Export a report for mailboxes homed on all your mailbox servers:

Get-ExchangeServer -Domain your domain name | Get-MailboxStatistics | sort TotalItemSize -Descending | select DisplayName, Database, StorageLimitStatus, @{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}}, @{label=”Deleted Item Size (MB)”;expression={$_.TotalDeletedItemSize.Value.ToMB()}} | epcsv driveletter:\foldername\reportname.csv

Obviously change -Ascending to -Descending so that the output is to your liking.