# Exchange 2013 Unattended Installation Script (Updated)

I’m pleased to announce the availability of Install-Exchange2013.ps1, a PowerShell script to perform a fully unattended setup of Exchange Server 2013 RTM or CU1.

The script takes care of:

• Installing required Windows Server 2008 R2 SP1 / 2012 features and optionally prepare Active Directory (phase 1);
• Install Exchange Server 2013 prerequisites (phase 2);
• Optionally install Exchange Server 2013 (phase 3)
• Optionally – depending on phase 3 – perform post-configuration (phase 4, tailor to your own needs);
• When done, the script will perform some cleaning up, like removing the state file and setting the startup of Transport Service to Automatic (phase 5).

Usage
This script version requires a domain-joined Windows Server 2012 system, 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-Exchange2013.ps1 -[InstallCAS|InstallMailbox|InstallBoth] -SourcePath <string> [-Organization <string>] [-MDBName <string>] [-MDBDBPath <string>] [-MDBLogPath <string>] [-InstallPath <string>] [-TargetPath <string>] [-AutoPilot] [-Credentials <pscredential>] [-NoSetup] [<CommonParameters>]

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.
• InstallCAS: Specifies you want to install the CAS role.
• InstallBoth: Specifies you want to install both the Mailbox server as well as the CAS role.
• 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.

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.

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-Exchange2013.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 including reboots and logons. 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.

Revision History
1.02: Fixes AD preparation logic and adds checks to see if domain is in native mode. It also fixes a small typo in the post-prepare AD function.
1.03: Tested against Exchange Server 2013 CU1, replaced installing OS features manually by using /InstallWindowsComponents and removed installation of Office Filtering Pack (routines still there because they’re required for the Exchange 2010 SP3 version I’m working on).
1.1: When AD was prepared, RSAT-ADDS-Tools won’t be uninstalled, pending reboot detection (in AutoPilot, script will reboot and restart phase), installs Server-Media-Foundation feature (UCMA 4.0 requirement), validates provided credentials for AutoPilot and checks OS version as string (should accommodate non-US OS).
1.5: Added support for WS2008R2 (i.e. added prereqs NET45, WMF3), IEESC toggling, KB974405, KB2619234, KB2758857 (supersedes KB2533623). Inserted phase for WS2008R2 for installing hotfixes; this phase is skipped for WS2012. Added InstallPath to AutoPilot set (or default won’t be set).
1.51: Rewrote Validate-Credentials due to missing .NET 3.5 Out of the Box in WS2008R2. Testing for proper loading of servermanager module in WS2008R2. Fixed logic in WS2008R2 SP1 detection.
1.52: Fix .NET / PrepareAD order for WS2008R2, relocated RebootPending check.
1.53: Fix phase of Forest/Domain Level check.
1.54: Added parameter InstallBoth to install CAS and Mailbox, workaround as PoSHv2 can discriminate overlapping ParameterSets (resulting in AmbigiousParameterSet).
1.55: Feature installation bug fix on WS2012.

## 49 thoughts on “Exchange 2013 Unattended Installation Script (Updated)”

1. Good job Michel.

• Thanks!

2. Great works!
Thanks Michel

3. Hi Michael
filter office pack and sp1 aren’t required for 2013
you can remove them from the script(its a TechNet error for basic office filtering not required)

• They are part of the official requirements. So, until that changes I’m inclined to leave them in there. People are free to comment them out in the installation script.

• great:)
you know who writes those docs right?
well, this is what he said…
Scott Schnoll

January 14, 2013 at 20:49

The Office Filter packs are not needed on Exchange 2013. The Search Foundation component includes all of the filters for Office already. I would also use the /InstallWindowsComponents setup switch and skip the manual installs of IIS and related components.

check the bottom here:
http://www.jaapwesselius.com/2013/01/04/installing-exchange-server-2013part-i/

4. Hi.. Great Job and thank you for sharing this.
I´m getting following error…
C:\Install\Install-Exchange2013.ps1 : Unexpected OS Version (6.2)
In Zeile:1 Zeichen:1
+ .\Install-Exchange2013 -Organization ‘EXLAB’ -InstallMailbox -MDBDBPath ‘D:\DB1′ …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-Exchange2013.ps1

5. I am having problems with the script when installing from a newly built 2012 server it fails to install the UCMA 4.0 runtime as the windows feature Server-Media-Foundation is not getting installed before UCMA 4.0 and it seems to be a prerequisite for this even though its not published. Have you seen this before?

• Using the latest script? Does it have (direct) internet access? If not, put the prerequisites in the installation folder (they will be picked up from there). I let Exchange setup install the Windows features etc. I haven’t seen it before; are you installing separate Mailbox roles only?

• I have downloaded all the prerequisite files manually and it launches the ucma 4.0 setup but then fails and when I manually run the ucma 4.0 setup it tells me I am missing the windows feature ‘media foundation’. This is before the exchange setup part of your script so the /installwindowsfeature isn’t relevant.

I got around it by un-commenting out the windows feature install of your script and adding server-media-foundation into that list of features.

• Of course; I will publish an update after I return from vacation (no RDP to home lab atm for testing).

6. Thanks for the script! I ran into a couple snags. One being the UCMA issue that you appear to be aware of. The other was that the Exchange installation was failing due to the ‘ol DiscoverySearchMailbox problems. The problem is the script wasn’t providing any visibility into the fact that the installation wasn’t completing successfully. As far as it knew everything went through fine, but the ClientAccess role wasn’t being installed (and I think the mailbox role was only partially installed).

I was able to launch setup through the GUI and it gave me the errors which I could then troubleshoot.

On an unrelated note – would it be possible to provide an option to NOT uninstall RSAT-ADDS-Tools after completion?

7. Greetings! I know this is somewhat off topic but I was wondering if
you knew where I could get a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m having problems finding one?

Thanks a lot!

8. Note: There looks to be a PowerShell v2 bug (as it works as expected in PSv3, ie WS2012). Cause is that on WS2008R2, you can’t either specify InstallCAS or InstallMailbox, only both. Apparantly, PSv2 can’t figure out what parameter set to use (should use “CM” variant) so it ends in AmbigiousParameterset. Note that when running help .\Install-Exchange2013.ps1 is shows that only specifying InstallMailbox or InstallCAS is a valid syntax. Standby while I look for a suited workaround.

9. Hi
Im testing the script with server2012 but get stuck with this error, how do I get around it
Checking Forest Functional Level
The following exception occurred while retrieving member “get”: “Unknown error (0×80005000)”
At C:\install\Install-Exchange2013.ps1:411 char:15
+ return( ([ADSI]“LDAP://cn=partitions,cn=configuration,$RootDSE”).get(“ms … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : CatchFromBaseGetMember Check-Sanity : Forest is not Functional Level 2003 or later At C:\install\Install-Exchange2013.ps1:906 char:5 + Check-Sanity + ~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Check-Sanity • Seems like an AD issue. Is the system domain joined? Are you logged on using a domain account? • Hi, yes you have right, was logged on with wrong account, it seems to work now. on this site you say that version 1.55 is the latest but if open the script it say’s 1.54 is that correct or is it a typo in the script file. Thank’s for your answer Robban • Thanks for catching that. Forgot to update header. Corrected; please use the the 1.55 one to prevent confusion. 10. Regarding “KB2758857: Insecure library loading could allow remote code execution (supersedes KB2533623)” – it supersedes KB2533623 for W2008 only, not for W2008R2. And the Exchange prerequisites page still says KB2533623 is required. 11. To check if this feature is installed, you should use If( ! (Get-WindowsFeature$Feat).Installed )
If( !( Get-WindowsFeature (\$Feat)))

Also, (at least for some features) reboot was required before they showed up as installed.

Great script, thanks!

• Thanks. On your remark: No – Get-WindowsFeature returns both features installed and available to be installed; I need to know if it’s installed or not.

12. Great script!

I installed a Exchange 2013 server with this script today and after the install i wanted to apply CU2
i got the following 3 errors

RSAT-Clustering-CmdInterface
FilterPack64bit
filterpack2010sp1-kb2460041-x64-fullfile-en-us

are not installed.

thnx

• Filterpacks aren’t required. What version are you trying to install, RTM/CU1? If so, why? You can install CU2 immediately, no need install RTM first then upgrade.

• Michel,

I installed RTM and then tried to upgrade to CU2 (yes i know next time install CU right away, but i forgot that CU2 was released) and de setup from CU2 gave me the error that i need to istall the 3 components above

• If I recall correctly, the filter packs will only result in a warning. They aren’t required. That issue with RSAT-Clustering-CmdInterface is a bit of quirk (it’s not required with fresh CU2 installs, just confirmed as I’m reinstalling some of my lab servers atm)

• Maybe it is just me but i wasn’t able to update to CU2
if you have time install a RTM with the script and try to install CU2

13. This is a great script. As FYI, it fails if there are spaces in the arguments, such as in the MDB path or the Exchange setup path. Once I removed them, it worked fine.

• Parameter values which contain spaces should be quoted.