Exchange Unplugged Lights Out Install

The title makes absolutely zero sense without a little bit of explanation :)

About 18months ago, Ewan, Eileen, John, Jason and I toured the country visiting partners and customers talking about Exchange 2003 SP2, Windows Mobile and generally encouraging customers to move off of 5.5 and onto Ex2003.

Well.... We are touring again, this time talking, explaining, demo'ing how to move from Ex2003 to Ex2007 - I can't publish the events registration links just yet, as soon as I can I will.

Nevertheless, one of the demo's will be what's known as a Lights Out install of Ex2007 - aka Unattended install.

Eileen is on the other side of the planet, in New Zealand at TechEd and has asked me to publish the Lights Out powershell script I will be using at the Exchange Unplugged events that will do the following - automatically - :

  • Install Ex2007 SP1 into an Ex2003 SP2 Organisation
  • Add the Exchange license key
  • Create numerous OU's in AD
  • Removes the default Storage Group and DB
  • Creates multiple SG's and DB's
  • Configures and enables LCR on one SG
  • Moves mailboxes from Ex2003 to Ex2007
  • Exports one mailbox to a PST ;)

It's a great demo and for those that come to an Unplugged event you will see it in action..!

Here's the script:

# Unplugged_Install.ps1
# Script will install Ex2007 SP1 into Ex2003 Org and move mailboxes to Ex2007
# Brettjo@Microsoft.com

        &"C:\bin\Setup.com" "/r:M,C,H" "/LegacyRoutingServer:Ex2003SP2.Brettjo.local"

#####################################
#Adding the Exchange Snapin into Windows Powershell#
#####################################

        Add-PsSnapin *Exchange*

################
#Adding the license key#
################

        Set-ExchangeServer -id "LOEx2007SP1" -ProductKey: 12345-12345-12345-12345

###############
#Setting the variables#
###############

        $server = hostname
$Domain = "dc=Brettjo,dc=local"
$AdminMbx = "$server\First Storage Group\Mailbox Database"
$AdminMbxName = "administrator@brettjo.local"

###############
#Import the CSV files#
###############

        $sgs = import-csv UnpluggedSG.csv
$mbxdbs = import-csv UnpluggedDBs.csv
$OUs = Import-csv UnpluggedOU.csv
$AllUsers = Import-csv UnpluggedUsers.csv

######################
#Create OU based on Database#
######################

        $OUs = Import-csv UnpluggedOU.csv
$objDomain = [ADSI]"LDAP://Ex2003SP2:389/OU=Unplugged,dc=Brettjo,dc=local"
foreach ($ou in $OUs) {
$objOU = $objDomain.Create("organizationalUnit", "ou=" + $ou.name)
$objOU.SetInfo()
}

############################
#Removing the pre-configured Databases#
############################

        get-mailboxdatabase -id "$server\First Storage Group\Mailbox Database" | Dismount-Database -confirm:$false

        get-mailboxdatabase -id "$server\First Storage Group\Mailbox Database" | remove-mailboxdatabase -confirm:$false

        get-storagegroup -id "$server\First Storage Group" | remove-StorageGroup -confirm:$false

#################
#Database Management#
#################

        $sgs = import-csv UnpluggedSG.csv
foreach ($sg in $sgs) {
new-storagegroup -Name $sg.Name -Server $server | ft Name,Server,ExchangeVersion
}

        $mbxdbs = import-csv UnpluggedDBs.csv
foreach ($mbxdb in $mbxdbs) {
new-mailboxdatabase -StorageGroup $mbxdb.StorageGroup -Name $mbxdb.Name | ft Name,Server,ExchangeVersion
}

        Get-MailboxDatabase -id "LOEx2007SP1\Unplugged_East\London" | mount-Database

###################
#Enable LCR on DB:London#
###################

        MKDIR c:\LCR

        Enable-DatabaseCopy -Id 'LOEX2007SP1\Unplugged_East\London' -CopyEdbFilePath 'C:\LCR\London.edb'

        Enable-StorageGroupCopy -Id 'LOEX2007SP1\Unplugged_East' -CopyLogFolderPath 'C:\LCR' -CopySystemFolderPath 'C:\LCR'

##########################
#Moving Users from Ex2003 to Ex2007#
#                   #################################################
#All users are moved to Ex2007 except administrator whose mailbox is copied to a PST :) #
##########################################################

        'Brettjo.local/Unplugged/Administrator' | move-mailbox -BadItemLimit '1' -TargetDatabase 'LOEX2007SP1\Unplugged_East\London' -GlobalCatalog 'Ex2003SP2.Brettjo.local' -DomainController 'Ex2003SP2.Brettjo.local' -confirm:$false

        'Brettjo.local/Unplugged/Eileen' | move-mailbox -BadItemLimit '1' -TargetDatabase 'LOEX2007SP1\Unplugged_East\London' -GlobalCatalog 'Ex2003SP2.Brettjo.local' -DomainController 'Ex2003SP2.Brettjo.local' -confirm:$false

        'Brettjo.local/Unplugged/Ewand' | move-mailbox -BadItemLimit '1' -TargetDatabase 'LOEX2007SP1\Unplugged_East\London' -GlobalCatalog 'Ex2003SP2.Brettjo.local' -DomainController 'Ex2003SP2.Brettjo.local' -confirm:$false
       

  'Brettjo.local/Unplugged/Julian' | move-mailbox -BadItemLimit '1' -TargetDatabase 'LOEX2007SP1\Unplugged_East\London' -GlobalCatalog 'Ex2003SP2.Brettjo.local' -DomainController 'Ex2003SP2.Brettjo.local' -confirm:$false
       

'Brettjo.local/Unplugged/Markdea' | move-mailbox -BadItemLimit '1' -TargetDatabase 'LOEX2007SP1\Unplugged_East\London' -GlobalCatalog 'Ex2003SP2.Brettjo.local' -DomainController 'Ex2003SP2.Brettjo.local'

        MKDIR C:\PSTs

        Export-Mailbox -Id Brettjo@Brettjo.local -PSTFolderPath C:\PSTs\Brettjo.pst