Can I ‘Shrink’ My Exchange Database?

KB ID 0001706

Problem

Saw this asked in a forum today, and my response was;

It never gets smaller, if you delete things out of it, it just creates more ‘whitespace’ within the database, unless you;

a) Take it offline, and defragment it using eseutil.
b) Move the mailboxes out of it, to another database and delete it.

Which is true, but even Microsoft say you should not need to defragment a database! Before you do anything make sure you have a good backup of Exchange and the mailbox databases!

Defragment an Exchange Database

Stop! Why are you doing this, if it’s because you are running out of room, then migrating mailboxes out of a database into another database, on another piece of storage with more room is what you should be doing, and does not involve long periods of downtime!

If you have just deleted hundreds of GB from a mailbox database, and you simply want to compress the DB, and you have a BIG window for downtime, (allow 1 hour for every 9GB of database size). Then you are in about the only use case scenario I can think of to want to do this!

Before You start: This process creates a temporary mailbox database, (you need to tell it where), if you are pressed for room, I suggest you add another volume/drive and put it there. (Though in my example I have room in the same folder). Allow for the entire database’s existing size plus ten percent to be on the safe side.

Let’s have a look, and see how  much room we might be able to reclaim (whitespace);

[box]

Get-MailboxDatabase -Status | Select Name, DatabaseSize, AvailableNewMailboxSpace

[/box]

The database has to be dismounted before you can run Eseutil on it (downtime starts here).

[box]

Dismount –Database Database Name

Eseutil /d C:\Folder\DatabaseName.edb> /t T:\Folder\TempDB.edb>"

[/box]

When complete, mount the datastore again, (downtime ends here).

[box]

Mount-Database Database Name

[/box]

Hopefully you should see the whitespace has decreased.

Don’t forget to set off a full backup of the store as soon at it’s back online.

Move Mailboxes To Another Exchange Database (To Reclaim Space)

This is the much more elegant solution, create a shiny new database move everything  from the old database into the new one, and delete the old database.

Will This Impact My Users? Any user using their mailbox while it is getting moved wont be affected, until the move is complete then they will see a popup that looks like;

The Microsoft Exchange administrator has made a change that requires you quit and restart Outlook.

Cool eh! So lets start by creating a New Mailbox Database.

[box]

New-MailboxDatabase -Name New Database Name -EdbFilePath C:\Folder\DB-Name.edb -LogFolderPath C:\Folder\Folder\

[/box]

Make sure you follow the advice and restart the information store, (yes you can mount the new DB and proceed, but Exchange does not allocate the resources correctly if you do this).

[box]

Restart-Service MSExchangeIS

[/box]

Let’s move our ‘Normal’ mailboxes to the new DB.

[box]

Get-Mailbox -Resultsize Unlimited | New-MoveRequest -TargetDatabase Target Database Name

[/box]

Depending on how many (and how large) mailboxes there are this can take a while, (days for large databases!) When they’ve all completed you need to remove the  move requests, (if you have any failures, or speed issues use the search box above, I’ve had to cope with thousands of these things not working correctly in my time!)

Let’s assume we are all moved, so we want to remove the move requests.

[box]

Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

[/box]

Now let’s see if we have any Arbitration Mailboxes, we do so let’s shift them;

[box]

Get-Mailbox -Database Source Database Name -Arbitration

Get-Mailbox -Database Source Database Name -Arbitration | New-MoveRequest -TargetDatabase Target Database Name

[/box]

Again, when complete, remove the move requests.

[box]

Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

[/box]

Now let’s see if we have any Auditlog Mailboxes, we do so let’s shift them;

[box]

Get-Mailbox -Database Source Database Name -Auditlog

Get-Mailbox -Database Source Database Name -Auditlog | New-MoveRequest -TargetDatabase Target Database Name

Get-MoveRequest | Get-MoveRequestStatistics

Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

[/box]

Now let’s see if we have any Archive Mailboxes, we do NOT so I will skip them, let’s check for Monitoring Mailboxes, we have those so let’s move them;

[box]

Get-Mailbox -Database Source Database Name -Archive

Get-Mailbox -Database Source Database Name -Monitoring

Get-Mailbox -Database Source Database Name -Monitoring | New-MoveRequest -TargetDatabase Target Database Name

[/box]

And clean those up as before.

[box]

Get-MoveRequest | Get-MoveRequestStatistics

Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

[/box]

Finally let’s see if we have any Public Folder Mailboxes, we have one of those so let’s move that;

[box]

Get-Mailbox -Database Source Database Name -PublicFolder

Get-Mailbox -Database Source Database Name -PublicFolder | New-MoveRequest -TargetDatabase Target Database Name
[/box]

We now need to remove the ‘Source‘ Database but first we need to dismount it.

[box]

Dismount-Database OLD Database Name

Remove-MailboxDatabase -Identity OLD Database Name

[/box]

I get an error message saying I cant delete the database.

 

Related Articles, References, Credits, or External Links

NA

Exchange – Move ‘ALL’ Mailboxes From One Database to Another

KB ID 0000864 

Problem

While replacing an Exchange Server on my test network last week, I needed to get all the mailboxes moved across to the new one. Exchange gets upset if you try and delete a mailbox database that has data in it.

Solution

1. Launch the Exchange Management Shell > Firstly lets get the names of my Databases, then I can simply copy and paste them into the move mailbox command.

[box]

Get-MailboxDatabase

Get-Mailbox -Database Source Database Name -ResultSize Unlimited | New-MoveRequest -TargetDatabase Target Database Name

[/box]

2. The Mailbox moves should then be queued, depending on how many there are, this can take some time to complete.

3. To check on progress issue the following command;

[box]

Get-MoveRequestStatistics -MoveRequestQueue Target Database Name

[/box]

 

4. When complete you should remove the movement requests like so;

[box]

Get-MoveRequest | where {$_.status -eq “Completed”} | Remove-MoveRequest

[/box]

5. That’s all the ‘user’ mailboxes, but your source database server may have system mailboxes in it. These will be either Arbitration mailboxes, or Archive Mailboxes (or both). I don’t have any archive mailboxes, but I do have Arbitration mailboxes. To find out for your databases, use the following commands;

[box]

Get-Mailbox -Database Source Database Name -Arbitration

[/box]

6. To move Arbitration and Archive mailboxes, use the following commands;

[box]

Get-Mailbox -Database Source Database Name -Arbitration | New-MoveRequest -TargetDatabase Target Database Name

Get-Mailbox -Database Source Database Name -Archive | New-MoveRequest -TargetDatabase Target Database Name

[/box]

7. You can monitor progress with the same command you used in step 3, and remove the move requests with the same command you used in step 4.

8. In addition you may also have some Auditlog mailboxes like so;

[box]

Get-Mailbox -Database Source Database Name -Auditlog | New-MoveRequest -TargetDatabase Target Database Name

[/box]

9. Also you may have Monitoring Mailboxes, (In the screenshot below you can see I don’t have any archive mailboxes, as the command returns no results)

[box]

Get-Mailbox -Database Source Database Name -Monitoring | New-MoveRequest -TargetDatabase Target Database Name

[/box]

10. When complete remove the move requests;

[box]

Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

[/box]

11. Finally on Exchange 2013 (and newer) you may also have Public Folder Mailbox(s).

[box]

Get-Mailbox -Database Source Database Name -PublicFolder | New-MoveRequest -TargetDatabase Target Database Name

[/box]

Don’t forget to remove any outstanding move requests.

Related Articles, References, Credits, or External Links

NA

Mac OSX: Creating ‘Password Protected’ Zip Files

KB ID 0001357

Problem

Me to the office: Does anyone know how to create a password protected Zip file on a Mac?

Reply: Use Windows

Well actually this advice is ‘bobbins!’ Windows still can’t do this without installing an application, (I would recommend 7-Zip). But with a Mac of course you can 🙂

Solution

First open an Terminal window, then ‘change directory’ to the folder that contains the uncompressed file(s), or folder(s) you want to Zip.

Changing Directory With Spaces In Your Foldernames

I thought I’d better put this here, if you have spaces in your folder names, you use the following syntax;

And repeat if you have multiple spaces like so;

Mac OSX: Create a Normal Zip File

Before we try and password protect a Zip, file let’s see how to create a simple one;

[box]zip -r {Archive-Name}.zip {Folder-or-Filename-To-Add}[/box]

Mac OSX: Adding Password Protection To Zip Files

Use the following syntax;

[box]zip -e {Archive-Name}.zip {Folder-or-Filename-To-Add}

Enter and Confirm The Password[/box]

Related Articles, References, Credits, or External Links

NA

Migrate Exchange 2010 to Exchange 2016 (& 2013)

Part 3

Migrating Certificates and Decommissioning Exchange 2010

KB ID 0000816

Problem

Continued from Migration From Exchange 2010 to Exchange 2016 Part 2

Solution

Exchange 2013/2016 Migration Step 8 Migrating Certificates from 2010 to 2016

Only consider doing this if you have a purchased (i.e. NOT using a self signed) certificate on your Exchange 2010 server. Bear in mind if you have the internal FQDN of your Exchange 2010 server as a SAN (Subject Alternative Name), then you cannot renew the certificate if it lasts longer than November 2013, so you might want to purchase a new one anyway.

Also make sure the public name of the server resolves to the public IP of the new server (or you change the port forwarding for HTTPS traffic to point to the new server).

1. On the Exchange 2010 Server > Launch the Exchange Management Console > Server Configuration > Select the certificate > Export Exchange Certificate.

2. Select a location to save the exported cert > supply a password > Next.

3. Finish.

4. On the Exchange 2013/2016 Server > Launch the Exchange Admin Center > Servers > Certificates > Select the ‘more options’ icon > Import Exchange Certificate.

5. Put in the path to where you saved the exported cert, and the password you used > Next.

6. Add in the Exchange 2016 Server > Finish.

7. Select the new certificate > Edit > Services > Select the service for which you want to use the certificate. Note: I don’t have Unified Messaging so I’m selecting all the other options > Save.

8. Answer ‘Yes’ to replace the self signed certificate that Exchange 2016 installs by default.

9. You can then open Outlook Web Access and give it a test (Remember to change the DNS records so that the Common Name on the certificate points to the new Exchange 2016 server).

Exchange 2013/2016 Migration Step 9 Decommissioning Exchange 2010

Before doing this: Have a quick common sense check!

  • Do you need to migrate any Transport rules? (For Exchange Disclaimers etc).
  • Do you need to change any Journaling settings for your third party Email Archive solutions etc.
  • Do you need to replicate ant receive connectors from the old email server to  the new one? (For Scanners, Photocopiers, SharePoint, SQL Mail, SAP, etc).

1. Before we can retire the old server we need to remove its databases, even though we have moved all the user mailboxes, If you try and delete the database it will complain that’s its not empty. This is because it will have either Archive or Arbitration mailboxes in it. To see, execute the following commands;

[box]

Get-Mailbox -Archive
Get-Mailbox -Arbitration

OR, If you have multiple source databases use the following syntax,

Get-Mailbox -Archive  | fl name,database
Get-Mailbox -Arbitration  | fl name,database

[/box]

As you can see (in the diagram below) I have Arbitration mailboxes left in the old Exchange 2010 database, to move them use the following command, Note: Execute this command from the Exchange 2013 Server!

[box] Get-Mailbox -Database “Mailbox-Database” -Arbitration | New-MoveRequest -TargetDatabase “Mailbox-Database-2016“[/box]

Obviously if you have archive mailboxes use the same command, but substitute archive for arbitration.

Note: Update 04/11/13 (Credit to Jeroen Bonenberg)

You may also have a Discovery Search Mailbox that will need migrating. To do so, use the following syntax.

[box]New-MoveRequest DiscoverySearchMailbox* -TargetDatabase “Mailbox-Database-2013[/box]

2. Wait a while and then check that they have moved. Note: You can check status with ‘Get-MoveRequest’.

3. In the Exchange Management Console > Organization Configuration > Mailbox > Database Management > Select the mailbox database > right click > Dismount Database.

4. Now Remove the database > Yes.

5. OK.

6. Offline Address Book Tab > Default Offline Address Book > Remove > Yes.

Note: If this OAB is still in use you will NOT be able to remove it, Go to the Address Book Policies tab > Change the default OAB from the 2010 one to the 2013 one.

7. If you try and remove the public folder database it will complain that it contains replicas, which you cant remove. The easiest way I’ve found to remove it is as follows. Dismount the public folder database.

8. Then delete (or move if you are paranoid) the database file (.edb file) and the logs for this database.

9. Then mount the database > Yes to all > It will mount a blank empty database.

10. You can now delete the database without error.

11. OK.

12. Close Exchange System Manager > Start > In the search/run box >appwiz.cpl {Enter} > Locate Microsoft Exchange Server 2010 > Uninstall.

13. Next.

14. Untick all the installed roles > Untick Management tools > Next.

15. Uninstall.

16. Finish.

Exchange 2013/2016 Migration Step 9 ‘Finish Up’

Remember if you are keeping this server, you might want to delete all the database files which get left behind. You will also want to change your backup software so that it is pointing to the new mailboxes/databases.

Related Articles, References, Credits, or External Links

Thanks to Shawn Welker for the Arbitration/Archive feedback
Thanks to leandro.chiesa for the OAB feedback

 

Cisco Catalyst – Upgrading IOS (via USB)

KB ID 0001056

Problem

Had a stack of 3560-X Switches to update today, and when I went looking for the notes I used last time, I could not find them. So This time I took the time to document the procedure.

Solution

Now I could load in the IOS image from TFTP like this, but last time I did this I used a spare USB drive and the image ‘tar’ file, and found it a lot less hassle.

1. Make sure you have formatted your dive at FAT32, download you image file to it and put it in the switch.

At console you should see something like this;

[box]Apr 22 13:13:18.466: %USBFLASH-5-CHANGE: usbflash0 has been inserted![/box]

2. Update the switch like so;

[box]

Petes-Switch#archive download-sw usbflash0:/c3560e-universalk9-tar.150-2.SE6.tar
examining image...
extracting info (110 bytes)
extracting c3560e-universalk9-mz.150-2.SE6/info (581 bytes)
extracting info (110 bytes)

System Type:             0x00000002
  Ios Image File Size:   0x0135B200
  Total Image File Size: 0x0187BA00
  Minimum Dram required: 0x08000000
  Image Suffix:          universalk9-150-2.SE6
  Image Directory:       c3560e-universalk9-mz.150-2.SE6
  Image Name:            c3560e-universalk9-mz.150-2.SE6.bin
  Image Feature:         IP|LAYER_3|PLUS|SSH|3DES|MIN_DRAM_MEG=128

Old image for switch 1: flash:/c3560e-universalk9-mz.122-55.SE8
  Old image will be deleted before download.

Deleting `flash:/c3560e-universalk9-mz.122-55.SE8' to create required space

————output removed for the sake of brevity————

extracting c3560e-universalk9-mz.150-2.SE6/dc_default_profiles.txt (66292 bytes)
extracting c3560e-universalk9-mz.150-2.SE6/c3560e-universalk9-mz.150-2.SE6.bin (20288000 bytes)
extracting info (110 bytes)

Installing (renaming): `flash:update/c3560e-universalk9-mz.150-2.SE6' ->
                                       `flash:/c3560e-universalk9-mz.150-2.SE6'
New software image installed in flash:/c3560e-universalk9-mz.150-2.SE6


All software images installed.
Petes-Switch#reload
Proceed with reload? [confirm]

*Mar  1 00:09:14.243: %SYS-5-RELOAD: Reload requested by console. Reload reason: Reload command

[/box]

3. At this point when the switch reloads, it will take a long time to boot as it performs a lot of updates and code rewrites when it restarts.

Upgrading The Catalyst Service Module

These switches have a 10Gb Service module in them that also needs updating, once the switch reboots you will have to wait a few minutes before the service module boots as well, if you don’t wait then you will see this; [box]

Petes-Switch#show switch service-modules
Switch/Stack supports service module CPU version: 03.00.76
                          Temperature                     CPU
Petes-Switch#  H/W Status       (CPU/FPGA)      CPU Link      Version
-----------------------------------------------------------------
 1             OK               48C/43C         notconnected  N/A

[/box]

You may also see an error like this (I’ve blogged this before).

[box]

Mar 30 01:29:55.128: POST: Macsec Uplink Loopback Tests : Passed Decryption Mode
Mar 30 01:29:57.594: POST: Macsec Uplink Loopback Tests : End
Mar 30 01:29:57.594: %PLATFORM-6-FRULINK_INSERTED: FRULink 10G SM module inserted.
Mar 30 01:32:13.188: %PLATFORM_SM10G-3-SW_VERSION_MISMATCH: The FRULink 10G Service Module
(C3KX-SM-10G) in switch 1 has a software version that is incompatible with the IOS software
 version. Please update the software. Module is in pass-thru mode.
Petes-Switch#show switch service-modules
Switch/Stack supports service module CPU version: 03.00.76
                          Temperature                     CPU
Petes-Switch#  H/W Status       (CPU/FPGA)      CPU Link      Version
-----------------------------------------------------------------
 1             OK               54C/54C         ver-mismatch  03.00.41

[/box]

Or it may simply look like this;

[box]

Mar 30 01:32:29.403: %PLATFORM_SM10G-6-LINK_UP: The FRULink 10G Service Module (C3KX-SM-10G)
communication has been established.
Petes-Switch#
Petes-Switch#show switch service-modules
Switch/Stack supports service module CPU version: 03.00.76
                          Temperature                     CPU
Petes-Switch#  H/W Status       (CPU/FPGA)      CPU Link      Version
-----------------------------------------------------------------
 1             OK               50C/48C         connected     03.00.76

[/box]

To perform the upgrade, you will need a matching image for the service module.

[box]

Petes-Switch#archive download-sw usbflash0:/c3kx-sm10g-tar.150-2.SE6.tar
examining image...
extracting info (100 bytes)
extracting c3kx-sm10g-mz.150-2.SE6/info (499 bytes)
extracting info (100 bytes)

System Type:             0x00010002
  Ios Image File Size:   0x017BDA00
  Total Image File Size: 0x017BDA00
  Minimum Dram required: 0x08000000
  Image Suffix:          sm10g-150-2.SE6
  Image Directory:       c3kx-sm10g-mz.150-2.SE6
  Image Name:            c3kx-sm10g-mz.150-2.SE6.bin
  Image Feature:         IP|LAYER_3|MIN_DRAM_MEG=128
  FRU Module Version:    03.00.76


Updating FRU Module on switch 1...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Updating FRU FPGA image...

FPGA image update complete.

All software images installed.
Petes-Switch#reload
Proceed with reload? [confirm]

Mar 30 01:47:19.459: %SYS-5-RELOAD: Reload requested by console. Reload Reason: Reload command.

[/box]

Related Articles, References, Credits, or External Links

Cisco Catalyst – Upgrading ‘Stacked’ Switches