Note: The script has been renamed to Install-Exchange15 to indicate support for installation of Exchange 2013 as well as Exchange 2016, as the internal major version number is 15 for both.
I’m pleased to announce the availability of Install-Exchange15.ps1, a PowerShell script to perform a fully automated unattended setup of Exchange Server 2013 or Exchange Server 2016.
The script takes care of:
- Installing required Windows Server 2008 R2 SP1 / 2012 / 2012 R2 features;
- Install Exchange Server prerequisites (phase 2);
- Install additional prerequisites and prepare Active Directory (phase 3);
- Optionally install Exchange Server 2013 or Exchange Server 2016 (phase 4)
- Optionally, install required fixes and perform post configuration, like setting your Power Plan to High Performance and if your pagefile is set to System Managed it will reconfigure it to best practices (memory + 10MB with a maximum of 32GB+10MB). Custom post-configuration is possible by modifying the script.
- Finally, the script will clean things up, like removing the state file and setting the startup of Transport Service back to Automatic (phase 6).
This script version requires a domain-joined Windows Server, an account to perform the installation (and optionally prepare Active Directory) and the location where the Exchange Server 2013 installation files are stored (e.g. an UNC path).
The syntax is as follows:
Install-Exchange15.ps1 [-InstallCAS|-InstallMailbox|-InstallMultiRole] -SourcePath [-Organization ] [-MDBName ] [-MDBDBPath ] [-MDBLogPath ] [-InstallPath ] [-TargetPath ] [-AutoPilot] [-Credentials ] [-NoSetup] [-IncludeFixes] [-InstallFilterPack] [-SCP] [-UseWMF3] [-Lock]
A short description of the parameters:
- Organization (optional): Specifies name of the Exchange organization to create. When omitted, the step to prepare Active Directory (PrepareAD) will be skipped.
- InstallMailbox: Specifies you want to install the Mailbox server role. Applies to Exchange 2013 as well as Exchange 2016.
- InstallCAS: Specifies you want to install the CAS role. Applies to Exchange 2013 only, ignored when installing Exchange 2016.
- InstallMultiRole:Specifies you want to install both Mailbox server and CAS roles. Applies to Exchange 2013 only.
- MDBName (optional): Specifies name of the initially created database.
- MDBDBPath (optional): Specifies database path of the initially created database (requires MDBName).
- MDBLogPath (optional): Specifies log path of the initially created database (requires MDBName).
- InstallPath (optional): Specifies (temporary) location of where to store prerequisites, transcript and state file. Default location is C:\Install.
- NoSetup (optional): Specifies you don’t want to perform Exchange setup.
- SourcePath: Specifies location of the Exchange 2013 installation files (setup.exe).
- TargetPath: Specifies the location where to install the Exchange 2013.
- AutoPilot (switch): Specifies you want to automatically restart, logon using credentials specified and continue the installation. When not specified, you will need to restart, logon and start the script manually each time (without parameters).
- Credentials (optional): Specifies credentials to use for automatic logon. Use DOMAIN\User or user@domain. When not specified, you will be prompted to enter credentials.
- IncludeFixes (optional). Depending on operating system and detected Exchange version to install, will download and install recommended hotfixes (e.g. KB2938053 or KB2997355).
- InstallFilterPack (optional). Adds installing Office filters for OneNote & Publisher support.
- UseWMF3 (optional) to install Windows Management Framework (WMF) 3 instead of WMF4 for Exchange 2013 SP1 or later.
- SCP (optional) allows you to reconfigure the Service Connection Point record for Autodiscover after Exchange setup has finished. Specify the full URI, e.g. https://autodiscover.contoso.com/autodiscover/autodiscover.xml. Use $null to clear the SCP entries of the server.
- Lock (optional) locks the system when running script.
Note that the script uses an XML file to store the (original) parameters used to start the script but also to keep track of the the process. Of course, if required, you can use predefined XML files to run the script without parameters.
Note that when not present, the script will try to download the prerequisites from the internet. When that isn’t possible or to save bandwidth, you can put them in the location defined by InstallPath and the script will detect and use them.
The post-configuration is currently adding IFilters for OneNote and Publisher (Mailbox) only. There are comments in the script where to add your own additional post-configuration steps.
For example, assume we want to start a fully unattended install of an Exchange Server 2013 Client Access server, using a network location for the Exchange Server 2013 source files. After setting the Execution Policy to Unrestricted and storing the script locally, we start the script using:
.\Install-Exchange15.ps1 –InstallCAS –SourcePath ‘\\server\share\isos\Microsoft\Exchange2013\mu_exchange_server_2013_x64_dvd_1112105’ –AutoPilot –Verbose
The script will perform some checks and since AutoPilot was specified without using the Credentials parameter, the script will ask for credentials.
After entering the credentials, the required features will be installed. Since OrganizationName wasn’t specified, Active Directory preparation will be skipped.
After rebooting, the system will automatically log on using the credentials specified earlier and start the script (RunOnce registry key is utilized for this purpose). It will read the last known state from the XML file and will continue with the next phase, which is downloading (when not present) and installing the Exchange prerequisites.
Next, after rebooting and the automatic logon, Exchange will be installed from the source location.
When done, the system will perform post configuration and finalization steps.
When running in AutoPilot mode, the system will automatically perform reboots and logons between the steps. Note that it may seem like a lot of reboots, but rebooting after installing Windows features and Exchange prerequisites is required anyway so I put reboots after the other milestones as well.
If you want to perform post-setup configuration of Exchange running Exchange cmdlets from the script, you need to tailor it to your needs. Locate the line which reads:
Uncomment this line so a proper Exchange Management Shell session will be set up to the local Exchange server. You can insert Exchange-related cmdlets after the Load-ExchangeModule line to configure your server. Be advised that you need to port modifications to new versions of the installation script.
Feedback is welcomed through the comments. If you got scripting suggestions or questions, do not hesitate using the contact form.
You can download Install-Exchange15.ps1 here from the Technet Gallery.
See Technet Gallery page.