Thursday, 29 September 2011

Part 8 - Setting up DAG on Exchange 2010 setup Multi-Tenancy

DAG is Exchange 2010 high availablility mode. This means that if a database corrupts or the server dies the flow of mail will not stop.

Before you do this you must know that the Windows server 2008 needs to be at least Enterprise Edition.

Also if you are planning on using more than 5 databases you will need Exchange Enterprise Edition also which hosts 100 databases.

So lets get started.

Use the cmdlet below and change the text in red to match your organisation.

New-DatabaseAvailabilityGroup -Name DAGname -WitnessServer Servername -WitnessDirectory  -WitnessDirectory C:
\Directoryonwitnessserver -DatabaseAvailabilityGroupIPAddresses free IP on the samevlan)

Add-DatabaseAvailabilityGroupServer DAGname -MailboxServer Firstmailboxserver

Add-DatabaseAvailabilityGroupServer DAGname -MailboxServer Secondboxserver

The above setups DAG and adds the 2 servers to it.

The below cmdlet copy's the database to server 2 and resumes it's ready for DAG

Add-MailboxDatabaseCopy -Identity 'Mailbox Database name' -MailboxServer 'Secondmailboxserver' -ActivationPreference '2'
Resume-MailboxDatabaseCopy -Identity 'Mailbox Database name\Secondboxserver'

Check the replication state of the server with:

Test-ReplicationHealth 'Firstmailboxserver'
Get-MailboxDatabaseCopyStatus -Identity 'Mailbox Database name'

Do the same as above but Visa versa for the other server.

Part 7 - Monitoring on Exchange 2010 setup Multi-Tenancy


To view how many items are in each mailbox on a database and to see if people have hit their mailbox limit use the cmdlet below. Change the red text to the name of your database name.

Get-MailboxStatistics -database "Mailbox Database"

To view an individuals quota use the cmdlet below. Remember to change the bits in Red to match your organisation.

Get-Mailbox "Joe Bloggs" -Organization orgname | Format-List *Quota

Part 6 - Organisation Management on Exchange 2010 setup Multi-Tenancy

In order to check what databases you have use the cmdlet


This will show you the mail server and the database running on it. It will also show recovery and replication type which we will cover later.


To set a quota on an organisation use the cmdlet below. Change the word in red to your organisation name and change the quota numbers to what you would like set(in bits)

Get-Mailbox -Organization Name | set-mailbox -IssueWarningQuota 235929600 -ProhibitSendQuota 262144000 -ProhibitSendReceiveQuota 262144000 -UseDatabaseQuotaDefaults $false

To set an individuals quota use the cmdlet below. Remember to change the bits in Red to match your organisation.

Get-Mailbox "Mailbox" -Organization Name | set-mailbox -IssueWarningQuota 235929600 -ProhibitSendQuota 262144000 -ProhibitSendReceiveQuota 262144000 -UseDatabaseQuotaDefaults $false

To check the individual quota use the cmdlet below. Remember to change the bits in Red to match your organisation.

Get-Mailbox "Joe Blogs" -Organization Orgname | Format-List *Quota

Part 5- Setting up Exchange through Citrix Xen App on Exchange 2010 setup Multi-Tenancy

Before a user can use the published outlook you must set it up on the server outlook will be published on. To achieve this I logged into Citrix gateway as the user and launched Outlook. This prompted me to setup a new account. So I went through the normal steps but when I got the point where I had to enter mailbox and exchange server name I did the following. Enter the mailbox server as normal and enter the users email address into the mailbox name. Then click more settings. In the security tab tick the box for "always ask for authentication". Then click check name and you should be prompted for credentials. Enter email address and exchange password and tick remember credentials. Once these are accepted you email should be underlined. Then go back into more settings, security and untick “always ask for authentication”. Then ok that and choose finish.

Now while still logged into the server launch outlook. If prompted again for credentials enter them again and click check name. Once this has opened you should be able to open through Citrix Gateway

Part 4 - Setting up send and receive connectors on Exchange 2010 setup Multi-Tenancy

Now you have your mailboxes you need to configure a connector to receive mail using the following command. Replace the red text with the name of your exchage server 

Set-ReceiveConnector -PermissionGroups 'AnonymousUsers, ExchangeUsers, ExchangeServers, ExchangeLegacyServers' -Identity 'Exchange\Default Exchange'

After this you need t setup your send connector. Please ensure you have your MX records assigned to the hub transport server you use. To create the send connector use the following command and remember to replace the red text with the hub transport server.

new-SendConnector -Name 'Using SmartHost' -Usage 'Custom' -AddressSpaces 'SMTP:*;1' -IsScopedConnector $false -DNSRoutingEnabled $true -UseExternalDNSServersEnabled $false -SourceTransportServers 'Exchange'

Now you should be able to send and receive mail.

Part 3 - Mailbox creation on Exchange 2010 setup Multi-Tenancy

Now you can setup your first mailbox. To do this use the following command. Change the email address in red and the organisation to the required one.

New-Mailbox "joe BLoggs" -UserPrincipalName joe.bloggs@domainname -Organization orgname

Repeat this until you have all the required mailboxes

If you need to delete a mailbox use the following command replacing the red text with the required mailbox emal address and organisation name

get-mailbox joe.bloggs@domainname -Organization orgname | remove-mailbox

Part 2 - Install Exchange server 2010 hosted and create organisation on Exchange 2010 setup Multi-Tenancy

I would recommend creating a server backup now and also after the install of exchange.
Then run the following command to install exchange 2010. At this point you will find out if you have missed anything. As long as the pre req's are all installed it should be fine. 

Setup.exe /mode:Install /roles:ClientAccess,Mailbox,HubTransport /hosting

Setup Organisation

Now you are ready to setup your first organisation.

Use Exchange Management shell from now unless told otherwise.

Firstly you need to create a default admin password for the organisation you are about to set up. You do this using the command

$c = get-credential

You will be prompted for a username and password. Set a username and password you want to use for th exchange administrator password for that organisation.
Then use the command to setup an organisation. Replace red text with your organisation details.

New-organization -name orgname -DomainName domainname -ProgramId HostingSample -OfferId 2 -location en-US -AdministratorPassword $c.password

The password entry $c.password means it will use the password you set for domain admin.

To remove and organisation use:

get-mailbox -Organization

orgname | remove-mailbox

Part 1 - Introduction to Exchange 2010 setup Multi-Tenancy

There are various guides on the internet about installing Exchange 2010 in hosting mode but you will find you have to search through lots of them to find bits of what you need. For some reason there does not seem to be a good complete one. That's now changed.

Why do I need hosted mode?

If you are here you probably already think you need it. Basically if you are an organisation hosting Exchange for more than one organisation then you will need to use hosted mode.

Whats so different?

Shell!!!!!!!  Yup that scary thing called powershell. You have to use this rather than the installation wizard to install in hosted mode. Worse still you cannot use the Exchange Management console to manage your exchange environment. You have to use Exchange Management Shell. This is a variation of powershell.

Lets get started...........

Log onto the server that is going to be an exchange server as a member of the domain with domain admin rights.

Make sure all the prerequisites are installed (found here

Add the IIS role with the following options:

Internet Information Service (IIS).
- World Wide Web service (W3SVC)
- Additional sub roles of W3SVC:
IIS 7 Basic Authentication
IIS 7 Windows Authentication
IIS 7 Digest Authentication
IIS 7 .NET Extensibility
IIS 7 Dynamic Content Compression
IIS 7 Static Content Compression
IIS 7 .NET Extensibility
IIS 6 Metabase Compatibility
IIS 6 Management Console
Web Server (IIS) Tools
- HTTP Activation
- Windows Process Activation Service Process Model

Once you have installed all the hotfixes and added the IIS role open Powershell as administrator.

Before you can install scripts you have to use the command:

Set-ExecutionPolicy unRestricted

I then used this script

Which I found did not install the prerequisite hotfixes but did no harm

Either download Exchange 2010 and add it as virtual disc using magic disk or burn and insert.

I then used cmd as administrator to run the following

Setup /PrepareAD /hosting

Setup /PrepareAllDomains /hosting

Setup /PrepareSchema /hosting

These commands setup the active directory structure ready or hosted installation. The /hosting switch is vital in these commands as I found out as missing one.