Exchange 2007 Install and Configuration from the command line (Part 3)

If you missed the previous parts in this article series please read:






In Part 1 of this series, I described the prerequisites required to install Exchange and then described the installation of Exchange and its verification. In Part 2, I moved on to describe some of the general configuration steps required to get the system operational, in particular focusing on the Client Access and Hub Transport roles. In this final part, I will complete the configuration of the single server Exchange organization by focusing on the Mailbox role.


Mailbox Configuration – Mailbox Server Preparation


Disable Scalable Network Pack


There have been various issues with the Scalable Network Pack (SNP) updates that have been released in the last year or so. The way I understand it, the SNP aims to offload processing to suitable Network Cards to improve performance. It would appear that these updates have caused Exchange to see connectivity problems. In order to ensure that the Scalability Networking Pack is disabled open a command prompt on all mailbox servers and run the following command:


Netsh int ip set chimney DISABLED


I should point out that this issue only affects Windows Server 2003 machines running Exchange because Windows Server 2008 machines have these enhancements disabled by default.


For much more info about the problems see the links below:


Windows 2003 Scalable Networking pack and its possible effects on Exchange


Windows 2003 Scalable Networking pack and its possible effects on Exchange (Part 2)


Global Mailbox Server Setup


Having completed the preparation steps above, I would now configure any global mailbox settings. In this case, that basically means ensuring any permission settings are correct to allow various add-on services to run properly.


Setup Blackberry Enterprise Server and Enterprise Vault Service Permissions


Although I do not have these services in my lab environment I thought it was worth mentioning how to setup permissions as it is such a common situation to face. The script below grants Organisation Administrator permissions to the Enterprise Vault service account and then grants the relevant permissions to get a BES service account working.

#Grant Org Admin to the SEV account
Add-ExchangeAdministrator EnterpriseVault -Role OrgAdmin
#Make the various BES service account View only Admins
Add-ExchangeAdministrator bessvc -Role ViewOnlyAdmin
#Grant permissions to the various BES service accounts to the Mailbox servers
Get-MailboxServer | Add-ADPermission -User bessvc -accessrights GenericRead, GenericWrite -extendedrights Send-As, Receive-As, ms-Exch-Store-Admin


Mailbox Server Setup


Having completed the organization wide configuration next I will move on to set up the individual mailbox servers to serve users.


Create Storage Groups


The first step is to create storage groups. Although there are default storage groups created I would first remove them so as to make use of a standard naming convention. In order to do this, the script below uses the Get-Database command to get all databases on the server Exch2007 and then pipes the output to the Dismount-Database command. The use of the Confirm:$false parameter means that we will not get prompted for each database. Having dismounted the databases they can then be removed. Of course this server not only has mailbox databases but also a public folder database. Before the storage groups can be removed, this public folder database also needs removing. This is a little trickier! I have struggled for ages to find a better way to do this, but Exchange plain refuses to let you remove the default public folder database. Therefore I use a little ADSI scripting to force it! First I set a variable to the Public Folder Database and then I use DeleteObject to remove it.

#Delete Existing Storage Groups and Databases
Get-MailboxDatabase -Server "Exch2007" | Dismount-Database -Confirm:$false
Get-MailboxDatabase -Server "Exch2007" | Remove-MailboxDatabase -Confirm:$false
Get-PublicFolderDatabase -Server "Exch2007" | Dismount-Database -Confirm:$false
$PFD = [ADSI]"LDAP://CN=Public Folder Database,CN=Second Storage Group,CN=InformationStore,CN=EXCH2007,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=GaotsOrg,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=gaots,DC=co,DC=uk"
Get-StorageGroup -Server "Exch2007" | Remove-StorageGroup -Confirm:$false


Having removed the default databases and storage groups, I can create new storage groups based on a naming standard. The script below does that, creating two storage groups, one for a Public Folder database and the other for a Mailbox database.

#Create Folders for Logs
New-Item C:\Logs -Type Directory
New-Item C:\Logs\SG-MBD-01 -Type Directory
New-Item C:\Logs\SG-PFD-01 -Type Directory
#Create new storage groups
New-StorageGroup -Name "SG-MBD-01" -LogFolderPath "C:\Logs\SG-MBD-01" -Server "Exch2007" -SystemFolderPath "C:\Logs\SG-MBD-01" 
New-StorageGroup -Name "SG-PFD-01" -LogFolderPath "C:\Logs\SG-PFD-01" -Server "Exch2007" -SystemFolderPath "C:\Logs\SG-PFD-01"


Create Databases


Having created new storage groups, next I will create some new databases using the script below which first creates the directories for storage and then creates the databases. You will note that I create the public folder database first so I can set it as the default Public Folder store when creating the mailbox database.

#Create folders for Databases
New-Item C:\DBs -Type Directory
New-Item C:\DBs\MBD-01 -Type Directory
New-Item C:\DBs\PFD-01 -Type Directory
#Create new public and mailbox databases
New-PublicFolderDatabase -Name PFD-01 -StorageGroup SG-PFD-01 -EdbFilePath C:\DBs\PFD-01\PFD-01.edb
New-MailboxDatabase -Name MBD-01 -StorageGroup SG-MBD-01 -EdbFilePath C:\DBs\MBD-01\MBD-01.edb -OfflineAddressBook "Default Offline Address List" -PublicFolderDatabase Exch2007\SG-PFD-01\PFD-01


Configure and Mount Databases


Having created the database the next step is to configure them and then mount them. The script below sets some common configuration parameters such as the deleted item retention period (set to 21 days), the maintenance schedule and quotas. You will notice that before configuring the mailbox database, you need to first create the journal recipient.

#Configure Public Folder Database
Set-PublicFolderDatabase -Identity PFD-01 -DeletedItemRetention 21.00:00:00 -MaintenanceSchedule "0.22:00-1.00:00","1.22:00-2.00:00","2.22:00-3.00:00","3.22:00-4.00:00","4.22:00-5.00:00","5.22:00-6.00:00","6.22:00-0.00:00" -IssueWarningQuota unlimited -MaxItemSize unlimited -ProhibitPostQuota unlimited -RetainDeletedItemsUntilBackup:$true
#Create journal mailbox
New-Mailbox -Name 'journal' -Alias 'journal' -OrganizationalUnit '' -UserPrincipalName '[email protected]' -SamAccountName 'journal' -FirstName 'journal' -Initials '' -LastName '' -Password 'System.Security.SecureString' -ResetPasswordOnNextLogon $false -Database 'EXCH2007\SG-MBD-01\MBD-01'
#Configure Mailbox Database
Set-MailboxDatabase -Identity MBD-01 -DeletedItemRetention 21.00:00:00 -JournalRecipient [email protected] -MaintenanceSchedule "0.22:00-1.00:00","1.22:00-2.00:00","2.22:00-3.00:00","3.22:00-4.00:00","4.22:00-5.00:00","5.22:00-6.00:00","6.22:00-0.00:00" -RetainDeletedItemsUntilBackup:$true -ProhibitSendQuota unlimited -ProhibitSendReceiveQuota unlimited -IssueWarningQuota unlimited -MailboxRetention 30.00:00:00 -PublicFolderDatabase Exch2007\SG-PFD-01\PFD-01 -OfflineAddressBook "Default Offline Address List"
#Mount the Databases
Get-PublicFolderDatabase -Server Exch2007 | Mount-Database
Get-MailboxDatabase -Server Exch2007 | Mount-Database


One thing to bear in mind when setting the maintenance schedule is that if your servers are in different time zones you must set this locally, because otherwise the way PowerShell handles the time means that you will end up with maintenance occurring not when you want due to the time zone shift!


Configure Standby Continuous Replication


At this point, I stray again from the one server environment I am working in, as I feel it is worth mentioning how easy it is to enable Standby Continuous Replication. The script below will do this for the storage group holding mailbox database I created earlier.

#Enable SCR
Enable-StorageGroupCopy –Identity SG-MBD-01 –StandbyMachine Server2 –ReplayLagTime 0.0:0:0


Public Folder Replication


Having completed the above configuration, we are now all but done, however there is one more important step to take, that of public folder replication.


Create Public Folder Replicas


The script below adds a public folder replica for all folders to the new Exchange 2007 public folder database.

#Add a replica of all public folders to the new 2007 Public folder databases
CD “C:\Program Files\Microsoft\Exchange Server\Scripts”
.\AddReplicaToPFRecursive.ps1 -TopPublicFolder \ -ServerToAdd Exch2007


Although the script will present an error about modifying the root folder, it will still progress and replicate all the other folders.


Create System Folder Replicas


Finally, it is important to ensure that the new server has a replica of all relevant system folders. In order to do this, I hit upon a problem with the AddReplicaToPFRecursive script. Basically it didn’t handle the use of public folders with spaces in the names. To fix this, you should open up the AddReplicaToPFRecursive script and then edit as below. Essentially you must add a single quote ‘ around the $TopPublicFolder in the two lines listed. That allows the script to recognise the entire string and not to break it at the first space.

if ($server)
                $getpfcmd = "get-publicfolder -server $Server -identity '$TopPublicFolder' -Recurse -resultsize unlimited"
                $getpfcmd = "get-publicfolder -identity '$TopPublicFolder' -Recurse -resultsize unlimited"


Having made the above change save the script and then use the commands below to add the replicas. You may receive an error but it does appear to still add the replicas.

#Add a replica of all relevant system folders to the new 2007 Public folder databases
CD “C:\Program Files\Microsoft\Exchange Server\Scripts”
.\AddReplicaToPFRecursive.ps1 -TopPublicFolder "\NON_IPM_Subtree\EFORMS REGISTRY" -ServerToAdd Exch2007
.\AddReplicaToPFRecursive.ps1 -TopPublicFolder "\NON_IPM_Subtree\OFFLINE ADDRESS BOOK" -ServerToAdd Exch2007
.\AddReplicaToPFRecursive.ps1 -TopPublicFolder "\NON_IPM_Subtree\SCHEDULE+ FREE BUSY" -ServerToAdd Exch2007


Areas of Configuration to Consider


Once you have walked through the above configuration scripts you should now have an operational Exchange 2007 server. All that remains is to move a few test users across and begin testing.


Obviously I have not been able to cover every possible scenario that you might come across but I have aimed to show how some of the most common are handled and hope that you can take the knowledge gained to investigate further some of the other areas which I didn’t cover.


One thing which I thought might be useful is the table below. My aim was to list the areas which I consider when configuring each of the Exchange roles. No doubt it is not entirely comprehensive but, it should give a good starting point!















Configure Certificates for SSL


Configure OAB distribution


Create postmaster mailbox


Subscribe the Edge Transport Server


Configure Dial Plan


Configure Outlook Anywhere


Configure New Address Lists


Configure Transport and Journaling Rules


Configure Anti-Spam/Anti-Virus


Configure UM IP Gateway


Configure ActiveSync and ActiveSync policies


Configure Managed Folder Mailbox Policy


Start EdgeSync


Configure Disclaimers


Configure UM Mailbox Policy


Create AutoDiscover DNS Record


Configure OOF


Configure connectors & accepted domains


Configure quarantine mailbox


Configure UM Auto Attendant


Set Ext URLs where required


Configure Backup


Configure Anti-Spam Agents if not using Edge


Enable Users for UM


Split logs and databases


Consider connection logging


Configure Replication


Set mail size limits


Set how the server identifies itself when sending mail


Allow internal servers to send mail


Configure or Migrate email address policies




This three part series has shown how to install and configure an Exchange 2007 server using the command line.


For any more info about the commands below I strongly suggest searching for them by name which will produce the Exchange documentation relevant to the command giving much more detail about syntax and available parameters.


Finally, I should say that although I have listed all the steps separately, you could easily save all the command in a .PS1 file and then sit back and wait for the server to complete configuring itself!


If you missed the previous parts in this article series please read:



About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top