Powered by Ed Buford and Coffee

Category: Exchange 2013

Clean that Database!

Clean Database command missing in Exchange 2013

Sometimes you need to disable a mailbox you need to be able to see it as a disconnected mailbox right away. In the Past you’ve been able to use the Clean-Mailboxdatabase command.  I would normally tend to run the clean command against all databases since the command doesn’t draw much in the way of resources. So for me the command would look like this:    Get-Mailboxdatabase | Clean-Mailboxdatabase

But as with everything the times are constantly changing and so are the commandlets that go with them. Which brings me to Exchange 2013 where the Clean-Mailboxdatabase command no longer works. Now the command is Update-StoreMailboxState and sadly it’s not a simple command to clean all the databases – in fact to run the command you need to know the database and mailbox GUID. Now this is going far… but I digress…

Anyway if you know the database you can attack it like this:

Get-MailboxStatistics –Database DB01 | ForEach { Update-StoreMailboxState -Database $_.Database -Identity $_.MailboxGuid -Confirm:$false }


GetMailboxStatistics Database MDB02 |ForEach { UpdateStoreMailboxState Database $_.Database Identity $_.MailboxGuid Confirm:$false }

It’s Midnight, Do you know where your FSW is?

Your FSW is more important than you may think!

Over the past couple of weeks I’ve seen two Database Availability Groups that had their File Share Witness go missing on them. In both cases the server which housed the FSW were replaced and the FSW role was not recreated.

I’m guessing you’re asking yourself “how that can ever happened?” The truth is it’s a lot easier than you think. With a 2 node cluster and File Share Witness you only need 2 nodes up to have a Quorum. This means if both of your DAG servers are up good, or if one DAG server a and the FSW is up you’re still good. The problem is that a well configured Exchange server is kind of “Set it and Forget it” and losing a FSW can have no impact on you at all when the Servers are both up. However when one of your servers go offline for whatever reason, the remaining server relies on the FSW to hold a quorum. IF you don’t have enough nodes to maintain a Quorum then all your Database will DISMOUNT!

This action is by design, there is a crazy thing that could happen to you called Split Brain where you would write different data to your 2 copies of the database that leaving it out of sync. Since you don’t that to happen you need the  FSW.  The FSW is a great thing that should not be forgotten!

One way to tell if your FSW is online is to use the Fail Over Clusters powershell tools. You can do that from your Exchange Server. I always do it from the Standard PowerShell console (I don’t know why) but the module will load into your EMS as well.

Import-Module FailOverClusters


Depending on your status the output should look like one of these:


Or you could create a task to in your event log to email you if this error shows up in your Event Logs


Here’s a link on how to do that:


Recover Deleted Items from Exchange Dumpster

I was having a conversation at lunch with a friend who needed to recover some items for a user from the Exchange Dumpster. So I came up with a one-liner to help you do just that but BEFORE i can really give you the one-liner I need to give you some background.

First there is a Deleted Items folder in your Exchange Mailbox. When you delete an email it goes here first (for many people that is as far as it goes but that’s another blog post…).
A user can simply look here in the their deleted Items folder and find something they have deleted if that folder has not yet been emptied.

If the Deleted Items folder has been emptied it will remain in the Deletions folder (Dumpster) for the next 14 days by default. During this time the user can use Outlook and or OWA to Recover Items that are now in the Dumpster.  I love this feature but it’s not very much fun for the user if they have deleted a lot of items lately. 

So to make things a little easier on the user you can recover all the items in PowerShell and then export them so the user can sort them to their hearts content.  The tricky part here is that you can’t drop them directly back into the mailbox you’re searching.  You can use the DiscoverySearchMailbox but I keep an admin mailbox around that I use for just such occasions. I call this mailbox SearchAdmin and it will become the Target mailbox.

The PowerShell command looks like this:

Search-Mailbox -identity ebuford -SearchDumpsterOnly -TargetMailbox SearchAdmin –TargetFolder ebufordDumpster

Search-Mailbox -identity ebuford -SearchDumpsterOnly -TargetMailbox SearchAdmin –TargetFolder ebufordDumpster

The three items in red are user mailbox you’re searching (ebuford) the target mailbox your dropping the files in (SearchAdmin) and the name of the Folder you want to dump them in (ebufordDumpster).

Once you’ve got them in the new folder you can export to a PST and then Import them back into the users mailbox. Now this isn’t the most straightforward admin task you’re going to do, but if you really want to please a user (or maybe your boss) this will make you some brownie points!


Import / Export PST files with Exchange 2010 and 2013

For many reasons we sometimes need to Import or Export all or part of a mailbox to or from a PST.  Before you can Import or Export you’ll need to have permission to actually SEE the commandlets in Exchange.

So start by getting the proper permissions you can give them to a user, in this case to ebuford:

New-ManagementRoleAssignment –Role "Mailbox Import Export" –User ebuford

If you’d rather give permissions to a security group like Administrators you can do that too:

New-ManagementRoleAssignment -Role "Mailbox Import Export" -SecurityGroup Administrators

Once you’ve given rights you’re going to need to log out and then log back in to see the commandlets.

If you’d like to know who has the role assigned to them:

Get-ManagementRoleAssignment -Role "mailbox import export"

Ok so now we have the role let’s get busy!

Let’s say you need to export a full mailbox to a PST here’s how we’ll tackle that. We will need to create an new export request using the New-MailboxExportRequest  commandlet.
Specify the username for the mailbox and then give a full UNC path for the PST file you’re exporting. You can’t use C:\PSTs\ebuford.pst it must be a full UNC path.  So if you’re trying to get to the PSTs folder on the C:\ drive of your exchange server named Exchange2013 then try this:  \\Exchange2013\C$\PSTs\ebuford.pst 

-Mailbox username -FilePath \\files\pstarchive

New-MailboxExportRequest -Mailbox ebuford –FilePath “\\FileServer\PSTs\ebuford.pst”

ok so you started the mailbox export and you want to see how it’s doing. You can get the stats for a single mailbox export like this:

Get-MailboxExportRequestStatistics ebuford\mailboxexport

But what if you have a few exports running at the same time?  Try this:

Get-MailboxExportRequest | Get-MailboxExportRequestStatistics

Ok what about Importing a PST?
Well it’s basically everything we just learned but we’re going to use the NewImportRequest Commandlet.

You can also use the Get-MailboxImportRequest and Get-MailboxImportRequestStatistics.

So far so good – now let’s talk a bit about some of the options for these commands.

Let’s say I’m exporting a pst but I don’t want objects from the deleted items folder. I can use the –ExcludeFolders parameter like this:
New-MailboxExportRequest -Mailbox ebuford  – ExcludeFolders #DeletedItems# –FilePath “\\FileServer\PSTs\ebuford.pst 

Make sure you place ## around the folder

Another option might be to only get the Inbox from a mailbox you can do this just as easily using the –IncludeFolders parameter like this:

New-MailboxExportRequest -Mailbox ebuford  – IncludeFolders #Inbox# –FilePath “\\FileServer\PSTs\ebuford.pst 

Here is a list of well- know folders:

  • Inbox
  • SentItems
  • DeletedItems
  • Calendar
  • Contacts
  • Drafts
  • Journal
  • Tasks
  • Notes
  • JunkEmail
  • CommunicationHistory
  • Voicemail
  • Fax
  • Conflicts
  • SyncIssues
  • LocalFailures
  • ServerFailures

Exchange Server Message Tracking

This morning an engineer came to me with some questions about message tracking in Exchange. I did 2 things for him I logged onto a server showed him how to get started with message tracking in PowerShell.  Then I sent him over to Paul Cunningham’s blog ExchangeServerPro to download the “Become a Message Tracking Master book”. Yes you have to register to become a member, but it’s free and if you’re reading this you will want to that anyway.

The free book is invaluable, Go get it!


Book Review: Microsoft Exchange Server 2013 High Availability

I just finished the Microsoft Exchange Server 2013 High Availability book from Nuno Mota.
I highly recommend it as the definitive resource for HA. But, I also recommend this book as the perfect reference for how many components of Exchange actually work. From Database Availability Groups  to the inner workings of the  Client Access Server.  Although the book is only 266 pages long it’s packed full of great information!
I highly recommend it.



Pin-Point DNS (Split- DNS Alternative)

Frequently you’re faced creating DNS records for internal objects that we don’t have a Zone for. If you create a Forward Lookup Zone for them then you need maintain it for ALL the external records to. just imagine the issues that come with that, but thankfully we can create a Pin-Point record that will solve this for us with very little effort.

First take a look at this internal DNS Server:


You can see here that I have an ExchangeNerd.Local zone but no
So if I wanted to create a record for you might think the first step is create a Zone for but instead we’re going to create a Zone for which is the External Name of my mail server.

Right Click Forward lookup Zone and Choose New Zone:


This will launch the New Zone Wizard – click next
Choose Primary Zone and Make sure the Checkbox is checked for Store In Active Directory.
Click Next


If you’re dealing with just a domain then Choose Zone Replication for Domain.
If you’re dealing with a Forest then choose Forest – If you don’t know then choose Domain ;-)


Now Name the Zone the FQDN of the External Record – in my case it’s


Choose Allow on Secure dynamic updates for this zone – then click next and finished to create the Zone.


Now you have a Pin- Point zone all you need to do now is point requests to you internal host.
Expand your new Zone and in the right hand pane right click and choose New Host Record:


Notice that if you leave the Host Name blank it uses the name of the zone which we just created – so leave that field blank and add the IP address of the internal resource:


Wait for AD replication to work and you’re done!


IIS Default Website connection logs taking a lot of space

While working on an Exchange server last week I notice the 120GB drive was almost full.  I had a guess what the issue was and I was right. The IIS connection logs were taking up 65GB of space.  Now I could have just deleted all the files but someday I would have to come back and do it again. So instead I broke out a great little command to delete these log files every Sunday if the logs are older than 30 days.  I’ve had this command archived for years now so I apologize that I can’t give credit to person who put it together originally – anyway here it is:

Open an command prompt as Administrator and type this in:

at 12:00 /EVERY:Su Forfiles.exe -p C:\InetPub\Logs\LogFiles\W3SVC1 -m *.log -d -30 -c \"Cmd.exe /C del @path\"

Take note of the Path as this can be in different place for you. Also if 30 days isn’t long enough you can change that by changing the –30 to –60 or –90 or whatever you like.

So that created the task but it has yet to run it, unless you have some time to kill to wait until Sunday for this to run you’ll want to kick it off on your own. So open your Task Scheduler and locate the command you just created, right click and choose Run.
If all went well when it completes it will say The operation completed successfully, (0x0)



Setting Mailbox Database Limits with PowerShell

While doing an install or migration of Exchange to a new server one of the things I often need to do is configure all the mailbox databases at once to unlimited.
Now this is something you can certainly in the GUI but if you have more than 1 database to change then the GUI gets old fast.
You can do this easily in the Exchange Management Shell.

First you might want to record the current settings. I would run this Command to view the current settings:
*in each of these examples change SERVERNAME to the name of your server.

Get-MailboxDatabase -Server SERVERNAME | FL name,issuewarningquota,prohibitsendquota,prohibitsendrecievequota

To set the Issue Warning Quota:

Get-MailboxDatabase -Server SERVERNAME | Set-MailboxDatabase -IssueWarningQuota unlimited


To Set the Prohibit Send Quota:

Get-MailboxDatabase -Server SERVERNAME | Set-MailboxDatabase -ProhibitSendQuota unlimited


To Set the Prohibit Send / Receive Quota:

Get-MailboxDatabase -Server SERVERNAME | Set-MailboxDatabase -ProhibitSendReceiveQuota unlimited


IF you want to set all at the same time:

Get-MailboxDatabase -Server SERVERNAME | Set-MailboxDatabase -IssueWarningQuota unlimited  -ProhibitSendReceiveQuota unlimited -ProhibitSendQuota unlimited


Simplifying Exchange 2013 URL

Thanks to a great Script from Pat Richard at Ehlo World I was able to do an HTTP Redirect to HTTPS without much effort for Exchange 2010 CAS servers.

Exchange 2013 is not as easy to do http redirection as 2010. It took a lot of trolling the forums to find a process that works for me and I thought I’d share it with you.

The process is three easy steps – make sure you do all three!

Step 1. Locate the Web.Config file it should be in your inetpub folder.  For most of us that’s  C:\inetpub\wwwroot but for many of you it could be located on another drive.

Open the Web.config file as an administrator file and open it with Notepad.

*Note Lines 2 and 4 I have added the <!–    –> comments to keep from loading the Modules. Add these comment brackets and save the file.

<!-- <modules>
<add name="OwaUrlModule" type="Microsoft.Exchange.HttpProxy.OwaUrlModule,Microsoft.Exchange.OwaUrlModule,Version=,Culture=neutral,PublicKeyToken=31bf3856ad364e35" preCondition="" />
</modules> -->



Step 2.  While you’re still working out of the Inetpub\wwwroot folder you’ll want to create a new file called Default.htm  and paste the code into it and save it.

<html><meta http-equiv="REFRESH" content="0;url=/owa"></HEAD></html>



Step 3.  Open IIS Manager and Highlight the Default Website.  In the Center pane under IIS choose Error Pages. In the Actions Pane choose Add and create a new Custom Error Page.

In the Status code box Type: 403.4  then choose the Respond with a 302 redirect and type the complete path to OWA



Once you’ve finished click ok and then Do an IISReset to start using the changes.