Jump to content


  • 0
Andersson

Exchange 2013 script – automatic installation of prerequisites

Question

I’ve updated a script that was intended for installing prerequisites for Exchange 2010 that were released by a couple of peoples (Anderson Patricio, Pat Richard and Bhargav Shukla). This script have now been updated and applies to Exchange 2013.

 

It will help you with installing all prerequisites (features) plus the FilterPack(s) and the Unified Communications Managed API. It also provides the option to disable the UAC (User Access Control) and the Windows Firewall.

 

You can download the script here

Feel free to use it as much as you want, I just want to mention I do not provide support for it and there are no warranty.

The script/code can be viewed below:

#############################################################################
 # Install-Exchange2013PreReqs.ps1
 # Configures the necessary prerequisites to install Exchange 2013 on a
 # Windows Server 2008 R2 server or Windows Server 2012 server
 #
 # Updated by: Jonas Andersson
 # Original written by: Pat Richard, Anderson Patricio and Bhargav Shukla
 #
 # Some info taken from
 # http://www.ucblogs.net/blogs/exchange/archive/2009/12/12/Automated-prerequisite-installation-via-PowerShell-for-Exchange-Server-2010-on-Windows-Server-2008-R2.aspx">http://www.ucblogs.net/blogs/exchange/archive/2009/12/12/Automated-prerequisite-installation-via-PowerShell-for-Exchange-Server-2010-on-Windows-Server-2008-R2.aspx
 # http://msmvps.com/blogs/andersonpatricio/archive/2009/11/13/installing-exchange-server-2010-pre-requisites-on-windows-server-2008-r2.aspx">http://msmvps.com/blogs/andersonpatricio/archive/2009/11/13/installing-exchange-server-2010-pre-requisites-on-windows-server-2008-r2.aspx
 # http://www.bhargavs.com/index.php/powershell/2009/11/script-to-install-exchange-2010-pre-requisites-for-windows-server-2008-r2/">http://www.bhargavs.com/index.php/powershell/2009/11/script-to-install-exchange-2010-pre-requisites-for-windows-server-2008-r2/
 #############################################################################
 
# Detect correct OS here and exit if no match
 if (-not((Get-WMIObject win32_OperatingSystem).OSArchitecture -eq '64-bit') -and (((Get-WMIObject win32_OperatingSystem).Version -eq "6.1.7601") -or (Get-WMIObject win32_OperatingSystem).Version -eq "6.2.9200")){
 Write-Host "This script requires a 64bit version of Windows Server 2008 R2 or Windows Server 2012, which this is not." -ForegroundColor Red -BackgroundColor Black
 Exit
 }
 
Function Disable-UAC(){
 
$path = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System"
 $a = Get-ItemProperty $path -Name EnableLUA
 
if ($a | Select-String "0")
 {
 Write-Host "UAC is already disabled" -ForegroundColor Green
 return
 }
 
if ($a | Select-String "1")
 {
 Write-Host "Enabled" -ForegroundColor Red
 Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value 0
 Write-host "Registry key HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA has been changed." -ForegroundColor yellow
 Write-Host "UAC is now disabled" -ForegroundColor Green
 }
 
}
 
Function Disable-FW(){
 
$status = netsh advfirewall show allprofiles state
 
if ($status | Select-String "ON")
 {
 $enabled = $true
 }
 else
 {
 $enabled = $false
 }
 
if ($enabled -eq $true) {
 
netsh advfirewall set allprofiles state off
 Write-Host "Firewall is now disabled" -ForegroundColor yellow
 return
 }
 
if ($enabled -eq $false) {
 Write-Host "Firewall is already disabled" -ForegroundColor Green
 }
 
}
 
Function InstallFilterPack(){
 
if (Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\{95140000-2000-0409-1000-0000000FF1CE}" -ErrorAction SilentlyContinue) {
 
Write-host "FilterPack is already installed." -ForegroundColor yellow
 return
 }
 
else
 {
 
trap {
 Write-Host "Problem downloading FilterPackx64.exe. Please visit: <a href="http://www.microsoft.com/en-us/download/details.aspx?id=26604">http://www.microsoft.com/en-us/download/details.aspx?id=26604</a> and <a href="http://www.microsoft.com/en-us/download/details.aspx?id=17062"'>http://www.microsoft.com/en-us/download/details.aspx?id=17062"">http://www.microsoft.com/en-us/download/details.aspx?id=17062"</a>
 
break
 }
 
#set a var for the folder you are looking for
 $folderPath = 'C:\Temp'
 
#Check if folder exists, if not, create it
 if (Test-Path $folderpath){
 Write-Host "The folder $folderPath exists."
 } else{
 Write-Host "The folder $folderPath does not exist, creating..." -NoNewline
 New-Item $folderpath -type directory | Out-Null
 Write-Host "done!" -ForegroundColor Green
 }
 
# Check if file exists, if not, download it
 $file1 = $folderPath+"\FilterPack64bit.exe"
 $file2 = $folderPath+"\filterpack2010sp1-kb2460041-x64-fullfile-en-us.exe"
 
if (Test-Path $file1){
 write-host "The file $file1 exists."
 } else {
 #Download Microsoft Filter Pack
 Write-Host "Downloading Microsoft Filter Pack..." -nonewline
 $clnt = New-Object System.Net.WebClient
 $url = "<a href="http://download.microsoft.com/download/0/A/2/0A28BBFA-CBFA-4C03-A739-30CCA5E21659/FilterPack64bit.exe"'>http://download.microsoft.com/download/0/A/2/0A28BBFA-CBFA-4C03-A739-30CCA5E21659/FilterPack64bit.exe"">http://download.microsoft.com/download/0/A/2/0A28BBFA-CBFA-4C03-A739-30CCA5E21659/FilterPack64bit.exe"</a>
 $clnt.DownloadFile($url,$file1)
 Write-Host "done!" -ForegroundColor Green
 }
 
if (Test-Path $file2){
 write-host "The file $file2 exists."
 } else {
 #Download Microsoft Filter Pack SP1
 Write-Host "Downloading Microsoft Filter Pack SP1..." -nonewline
 $clnt = New-Object System.Net.WebClient
 $url = "<a href="http://download.microsoft.com/download/A/A/3/AA345161-18B8-45AE-8DC8-DA6387264CB9/filterpack2010sp1-kb2460041-x64-fullfile-en-us.exe"'>http://download.microsoft.com/download/A/A/3/AA345161-18B8-45AE-8DC8-DA6387264CB9/filterpack2010sp1-kb2460041-x64-fullfile-en-us.exe"">http://download.microsoft.com/download/A/A/3/AA345161-18B8-45AE-8DC8-DA6387264CB9/filterpack2010sp1-kb2460041-x64-fullfile-en-us.exe"</a>
 $clnt.DownloadFile($url,$file2)
 Write-Host "done!" -ForegroundColor Green
 }
 
#Install Microsoft Filter Packs
 Write-Host "Installing Microsoft Filter Packs..."
 
$args = "/quiet /norestart"
 $setup1 = (Start-Process $file1 -ArgumentList $args -Wait -PassThru).ExitCode
 if ($setup1 -eq 0) { write-host "Successfully installed $file1" -ForegroundColor Green }
 if ($setup1 -ne 0) { write-host "Failed!" -ForegroundColor Red }
 
$setup2 = (Start-Process $file2 -ArgumentList $args -Wait -PassThru).ExitCode
 if ($setup2 -eq 0) { write-host "Successfully installed $file2" -ForegroundColor Green }
 if ($setup2 -ne 0) { write-host "Failed!" -ForegroundColor Red }
 
}
 }
 
Function InstallUMAPI(){
 
#Change reg key below!
 if (Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\UCMA4" -ErrorAction SilentlyContinue) {
 
Write-host "Unified Communications Managed API 4.0 Runtime is already installed." -ForegroundColor yellow
 return
 }
 
else
 {
 
trap {
 Write-Host "Problem downloading UM API. Please visit: <a href="http://www.microsoft.com/en-us/download/details.aspx?id=34992"'>http://www.microsoft.com/en-us/download/details.aspx?id=34992"">http://www.microsoft.com/en-us/download/details.aspx?id=34992"</a>
 
break
 }
 #set a var for the folder you are looking for
 $folderPath = 'C:\Temp'
 
#Check if folder exists, if not, create it
 if (Test-Path $folderpath){
 Write-Host "The folder $folderPath exists."
 } else{
 Write-Host "The folder $folderPath does not exist, creating..." -NoNewline
 New-Item $folderpath -type directory | Out-Null
 Write-Host "done!" -ForegroundColor Green
 }
 
# Check if file exists, if not, download it
 $file = $folderPath+"\UcmaRuntimeSetup.exe"
 if (Test-Path $file){
 write-host "The file $file exists."
 } else {
 
#Download Microsoft UM API
 Write-Host "Downloading Microsoft UM API..." -nonewline
 $clnt = New-Object System.Net.WebClient
 $url = "<a href="http://download.microsoft.com/download/2/C/4/2C47A5C1-A1F3-4843-B9FE-84C0032C61EC/UcmaRuntimeSetup.exe"'>http://download.microsoft.com/download/2/C/4/2C47A5C1-A1F3-4843-B9FE-84C0032C61EC/UcmaRuntimeSetup.exe"">http://download.microsoft.com/download/2/C/4/2C47A5C1-A1F3-4843-B9FE-84C0032C61EC/UcmaRuntimeSetup.exe"</a>
 $clnt.DownloadFile($url,$file)
 Write-Host "done!" -ForegroundColor Green
 }
 
#Check/Install Media Foundation feature
 $mf = Get-WindowsFeature "Server-Media-Foundation" | select *
 
Start-Sleep 2
 
if ($mf.Installed -eq $False)
 {
 Write-Host "Installing Media Foundation feature..."    -ForegroundColor Green
 Add-Windowsfeature Server-Media-Foundation
 
Write-Host ""
 Write-Host "Installing of Media Foundation feature completed." -ForegroundColor Green
 Write-Host ""
 Write-Host "Restart the server and restart the task" -ForegroundColor Red
 Write-Host "or else the UM API won't be installed" -ForegroundColor Red
 Write-Host ""
 
return
 
}
 
if ($mf.Installed -eq $True)
 {
 #Install Microsoft UM API
 Write-Host "Installing Microsoft UM API..." -ForegroundColor Green
 
$args = "/quiet /norestart"
 $setup = (Start-Process $file -ArgumentList $args -Wait -PassThru).ExitCode
 if ($setup -eq 0) { write-host "Successfully installed $file" -ForegroundColor Green }
 if ($setup -ne 0) { write-host "Failed!" -ForegroundColor Red }
 
}
 }
 
}
 
Import-Module ServerManager
 $opt = "None"
 # Do {
 clear
 if ($opt -ne "None") {write-host "Last command: "$opt -foregroundcolor Yellow}
 write-host
 write-host Exchange Server 2013 - Prerequisites script
 write-host Please, select which role you are going to install..
 write-host
 write-host '1) Client Access Server'
 write-host '2) Mailbox'
 write-host '3) Typical (CAS/Mailbox)'
 write-host
 write-host '10) Install Microsoft Filter Pack 2.0'
 write-host '    Required if installing Mailbox Server roles' -foregroundcolor yellow
 write-host '    Automatically set for options 2 and 3' -foregroundcolor yellow
 write-host '11) Install Microsoft UM API'
 write-host '    Required if installing Mailbox Server roles' -foregroundcolor yellow
 Write-Host '12) Disable UAC'
 Write-Host '13) Disable Firewall'
 write-host
 write-host '15) Restart the Server'
 write-host '16) End'
 write-host
 $opt = Read-Host "Select an option.. [1-14]? "
 
switch ($opt)    {
 1 {
 
# Windows Server 2008 R2 SP1
 if ((Get-WMIObject win32_OperatingSystem).Version -eq "6.1.7601") {
 
Import-Module ServerManager
 Add-WindowsFeature "Desktop-Experience", "NET-Framework", "NET-HTTP-Activation", "RPC-over-HTTP-proxy", "RSAT-Clustering", "RSAT-Web-Server", "WAS-Process-Model", "Web-Asp-Net", "Web-Basic-Auth", "Web-Client-Auth", "Web-Digest-Auth", "Web-Dir-Browsing", "Web-Dyn-Compression", "Web-Http-Errors", "Web-Http-Logging", "Web-Http-Redirect", "Web-Http-Tracing", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Lgcy-Mgmt-Console", "Web-Metabase", "Web-Mgmt-Console", "Web-Mgmt-Service", "Web-Net-Ext", "Web-Request-Monitor", "Web-Server", "Web-Stat-Compression", "Web-Static-Content", "Web-Windows-Auth", "Web-WMI" -restart
 
}
 
# Windows Server 2012
 if ((Get-WMIObject win32_OperatingSystem).Version -eq "6.2.9200") {
 
Install-WindowsFeature "AS-HTTP-Activation", "Desktop-Experience", "NET-Framework-45-Features", "RPC-over-HTTP-proxy", "RSAT-Clustering", "RSAT-Clustering-CmdInterface", "RSAT-Clustering-Mgmt", "RSAT-Clustering-PowerShell", "Web-Mgmt-Console", "WAS-Process-Model", "Web-Asp-Net45", "Web-Basic-Auth", "Web-Client-Auth", "Web-Digest-Auth", "Web-Dir-Browsing", "Web-Dyn-Compression", "Web-Http-Errors", "Web-Http-Logging", "Web-Http-Redirect", "Web-Http-Tracing", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Lgcy-Mgmt-Console", "Web-Metabase", "Web-Mgmt-Console", "Web-Mgmt-Service", "Web-Net-Ext45", "Web-Request-Monitor", "Web-Server", "Web-Stat-Compression", "Web-Static-Content", "Web-Windows-Auth", "Web-WMI", "Windows-Identity-Foundation" -restart
 
}
 
}
 
2 {
 
# Windows Server 2008 R2 SP1
 if ((Get-WMIObject win32_OperatingSystem).Version -eq "6.1.7601") {
 
Import-Module ServerManager
 InstallFilterPack
 Add-WindowsFeature "Desktop-Experience", "NET-Framework", "NET-HTTP-Activation", "RPC-over-HTTP-proxy", "RSAT-Clustering", "RSAT-Web-Server", "WAS-Process-Model", "Web-Asp-Net", "Web-Basic-Auth", "Web-Client-Auth", "Web-Digest-Auth", "Web-Dir-Browsing", "Web-Dyn-Compression", "Web-Http-Errors", "Web-Http-Logging", "Web-Http-Redirect", "Web-Http-Tracing", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Lgcy-Mgmt-Console", "Web-Metabase", "Web-Mgmt-Console", "Web-Mgmt-Service", "Web-Net-Ext", "Web-Request-Monitor", "Web-Server", "Web-Stat-Compression", "Web-Static-Content", "Web-Windows-Auth", "Web-WMI" -restart
 
}
 
# Windows Server 2012
 if ((Get-WMIObject win32_OperatingSystem).Version -eq "6.2.9200") {
 
InstallFilterPack
 Install-WindowsFeature "AS-HTTP-Activation", "Desktop-Experience", "NET-Framework-45-Features", "RPC-over-HTTP-proxy", "RSAT-Clustering", "RSAT-Clustering-CmdInterface", "RSAT-Clustering-Mgmt", "RSAT-Clustering-PowerShell", "Web-Mgmt-Console", "WAS-Process-Model", "Web-Asp-Net45", "Web-Basic-Auth", "Web-Client-Auth", "Web-Digest-Auth", "Web-Dir-Browsing", "Web-Dyn-Compression", "Web-Http-Errors", "Web-Http-Logging", "Web-Http-Redirect", "Web-Http-Tracing", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Lgcy-Mgmt-Console", "Web-Metabase", "Web-Mgmt-Console", "Web-Mgmt-Service", "Web-Net-Ext45", "Web-Request-Monitor", "Web-Server", "Web-Stat-Compression", "Web-Static-Content", "Web-Windows-Auth", "Web-WMI", "Windows-Identity-Foundation" -restart
 
}
 
}
 
3 {
 
if ((Get-WMIObject win32_OperatingSystem).Version -eq "6.1.7601") {
 
Import-Module ServerManager
 InstallFilterPack
 Add-WindowsFeature "Desktop-Experience", "NET-Framework", "NET-HTTP-Activation", "RPC-over-HTTP-proxy", "RSAT-Clustering", "RSAT-Web-Server", "WAS-Process-Model", "Web-Asp-Net", "Web-Basic-Auth", "Web-Client-Auth", "Web-Digest-Auth", "Web-Dir-Browsing", "Web-Dyn-Compression", "Web-Http-Errors", "Web-Http-Logging", "Web-Http-Redirect", "Web-Http-Tracing", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Lgcy-Mgmt-Console", "Web-Metabase", "Web-Mgmt-Console", "Web-Mgmt-Service", "Web-Net-Ext", "Web-Request-Monitor", "Web-Server", "Web-Stat-Compression", "Web-Static-Content", "Web-Windows-Auth", "Web-WMI" -restart
 
}
 
# Windows Server 2012
 if ((Get-WMIObject win32_OperatingSystem).Version -eq "6.2.9200") {
 
InstallFilterPack
 Install-WindowsFeature "AS-HTTP-Activation", "Desktop-Experience", "NET-Framework-45-Features", "RPC-over-HTTP-proxy", "RSAT-Clustering", "RSAT-Clustering-CmdInterface", "RSAT-Clustering-Mgmt", "RSAT-Clustering-PowerShell", "Web-Mgmt-Console", "WAS-Process-Model", "Web-Asp-Net45", "Web-Basic-Auth", "Web-Client-Auth", "Web-Digest-Auth", "Web-Dir-Browsing", "Web-Dyn-Compression", "Web-Http-Errors", "Web-Http-Logging", "Web-Http-Redirect", "Web-Http-Tracing", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Lgcy-Mgmt-Console", "Web-Metabase", "Web-Mgmt-Console", "Web-Mgmt-Service", "Web-Net-Ext45", "Web-Request-Monitor", "Web-Server", "Web-Stat-Compression", "Web-Static-Content", "Web-Windows-Auth", "Web-WMI", "Windows-Identity-Foundation" -restart
 
}
 
}
 10 {
 # future - auto detect Internet access
 write-host 'Can this server access the Internet?'
 $filtpack = read-host 'Please type (Y)es or (N)o...'
 switch ($filtpack)                {
 Y { InstallFilterPack }
 N {Write-warning 'Please download and install Microsoft Filter Pack from here: <a href="http://www.microsoft.com/en-us/download/details.aspx?id=26604">http://www.microsoft.com/en-us/download/details.aspx?id=26604</a> and <a href="http://www.microsoft.com/en-us/download/details.aspx?id=17062'}">http://www.microsoft.com/en-us/download/details.aspx?id=17062'}</a>
 }
 }
 11 {
 # future - auto detect Internet access
 write-host 'Can this server access the Internet?'
 $umapi = read-host 'Please type (Y)es or (N)o...'
 switch ($umapi)                {
 Y { InstallUMAPI }
 N {Write-warning 'Please download and install Microsoft UM API from here: <a href="http://www.microsoft.com/en-us/download/details.aspx?id=34992'}">http://www.microsoft.com/en-us/download/details.aspx?id=34992'}</a>
 }
 }
 12 { Disable-UAC }
 13 { Disable-FW }
 15 { Restart-Computer }
 16 {
 Write-Host "Exiting..."
 Exit
 }
 default {write-host "You haven't selected any of the available options. "}
 }

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.