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, Exchange Server 2016 or Exchange Server 2019 (Desktop and Core) is supported).
The script takes care of:
- Installing required Windows Server 2008 R2 SP1, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016 or Windows Server 2019 feats.
- Install Exchange Server prerequisites, e.g. .NET Framework 4.5.2/4.6.1/4.6.2/4.7.1/4.7.2 and Visual C++ Runtime 2012 or 2013, depending on roles, OS and Exchange version to install.
- Install additional prerequisites and prepare Active Directory.
- Optionally install Exchange Server 2013 / 2016 / 2019.
- Optionally, install required fixes and perform post configuration, like setting your Power Plan to High Performance, reconfiguring the pagefile to best practices (memory + 10MB with a maximum of 32GB+10MB) if it is system managed, and performing .NET framework optimizations. Custom post-configuration is possible by modifying the script.
- On Windows Server 2016 and later, it will configure Windows Defender exclusions when present.
- Finally, the script will clean things up, like removing the state file and setting the startup of Transport Service back to Automatic.
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/2016/2019 installation files are stored (e.g. an UNC path).
The syntax is as follows:
Install-Exchange15.ps1 -[InstallCAS|InstallMailbox|InstallMultiRole|InstallEdge|Recover|NoSetup] -SourcePath [-Organization ] [-MDBName ] [-MDBDBPath ] [-MDBLogPath ] [-InstallPath ] [-TargetPath ] [-AutoPilot] [-Credentials ] [-IncludeFixes] [-SCP] [-UseWMF3] [-DisableSSL3] [-Lock] [-SkipRolesCheck]
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.
- InstallEdge: Specifies to install the Edge Transport rule (Exchange 2013/2016).
- 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 locate – and when downloaded store – prerequisite files, the state file and log files. Default location is C:\Install. You can also use a UNC path to use a central location, given the credentials have sufficient permissions to write at this location. This is ideal when you want the script to use previously downloaded hotfix files, for example, as some required hotfixes are quite large (e.g. KB3206632 for WS2016 ~ 1GB, KB2919355 for WS2012R2 ~ 700MB).
- NoSetup (optional): Specifies you only want to install prerequisites (and optionally prepare the Exchange organization), Exchange setup and post-configuration steps are not performed. You still need to specify SourcePath because the Exchange version will determine the prerequisites to install.
- Recover: Specifies you want to install this server in Recovery mode. The script will check if an Exchange server object is already defined.
- SourcePath: Specifies location of the Exchange 2013 installation files. This can point to the location of setup.exe, or the location of the ISO.
- 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.
- 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 ‘-‘ to clear the SCP entries of the server.
- Lock (optional) locks the system when running script.
- NoNET471 (optional) to use .NET Framework 4.6.2, even when installing an Exchange version which is supported with .NET Framework 4.7.1.
- NoNET461 (optional) to use .NET Framework 4.5.2, even when installing an Exchange version which is supported with .NET Framework 4.6.1 or higher.
- DisableSSL3 (optional) to disable SSL3 protocol as per KB187498.
- DisableRC4 (optional) to disable RC4 cipher as per KB2868725.
- SkipRolesCheck (optional) to bypass membership checks for Schema Admin and Enterprise Admin roles.
- EdgeDNSSuffix specifies the DNS suffix to configure on the primary NIC.
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.
The script also supports recovery mode (/mode:RecoverServer). After checking the Exchange server object is present in Active Directory, installation will proceed as normal, with the exception of running setup in recovery mode. For example:
.\Install-Exchange15.ps1 -Recover -Autopilot -InstallPath \\server1\exfiles \\server1\sources\ex2013cu1
The script also supports update mode (/mode:Update). After checking the Exchange server object is present in Active Directory, and checking for presence of Exchange installation, installation will proceed as normal, with the exception of running setup in Update mode.
Feedback is welcomed through the comments. If you got scripting suggestions or questions, do not hesitate using the contact form.
See Technet Gallery page.