Script to install Exchange 2010 pre-requisites for Windows Server 2008 R2
Even though installing pre-requisites on Windows Server 2008 R2 is simple and straight forward as described here, it makes it even faster if you were to use a script to do so.
MVP Anderson Patricio recently published a script for the same. What the script did not do is what I took liberty to add. I am publishing entire script below with credit to Anderson where it is due.
My code adds functionality to download and install Microsoft Filter Pack if the server has internet connectivity.
UPDATE: Pat Richard enhanced this script and added some checks and other functionality which makes it even more useful. You can read Pat’s post here. The script below is result of combined effort of Anderson, Pat and myself.
#############################################################################
# Set-Exchange2010Prereqs.ps1
# Configures the necessary prerequisites to install Exchange 2010 on a
# Windows Server 2008 R2 server
#
# Pat Richard, MVP
# http://ucblogs.net/blogs/exchange
#
# 1.0 – Original script 11/27/09 based on the work of Anderson Patricio and
# Bhargav Shukla
#
# Dedicated blog post:
# 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
#
# Some info taken from
# http://msmvps.com/blogs/andersonpatricio/archive/2009/11/13/installing-exchange-server-2010-pre-requisites-on-windows-server-2008-r2.aspx
# https://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.7600'){
Write-Host "This script requires a 64bit version of Windows Server 2008 R2, which this is not." -ForegroundColor Red -BackgroundColor Black
Exit
}
Function InstallFilterPack(){
# future: look and see if it's already installed
# via registry HKLM:\Software\Microsoft\CurrentVersion\Uninstall\{95120000-2000-0409-1000-0000000FF1CE}
trap {
Write-Host "Problem downloading FilterPackx64.exe. Please visit http://tinyurl.com/36yrlj"
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+"\FilterPackx64.exe"
if (Test-Path $file){
write-host "The file $file exists."
} else {
#Download Microsoft Filter Pack
Write-Host "Downloading Microsoft Filter Pack..." -nonewline
$clnt = New-Object System.Net.WebClient
$url = "http://download.microsoft.com/download/b/e/6/be61cfa4-b59e-4f26-a641-5dbf906dee24/FilterPackx64.exe"
$clnt.DownloadFile($url,$file)
Write-Host "done!" -ForegroundColor Green
}
#Install Microsoft Filter Pack
Write-Host "Installing Microsoft Filter Pack..." -nonewline
$expression = $folderPath+"\FilterPackx64.exe /quiet /norestart"
Invoke-Expression $expression
Start-Sleep -Seconds 10
write-host "done!" -ForegroundColor Green
}
Function SetRunOnce(){
# Sets the NetTCPPortSharing service for automatic startup before the first reboot
# by using the old RunOnce registry key (because the service doesn't yet exist, or we could
# use 'Set-Service')
$hostname = hostname
$RunOnceCommand = "sc \\$hostname config NetTcpPortSharing start= auto"
if (Get-ItemProperty -Name "NetTCPPortSharing" -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce' -ErrorAction SilentlyContinue) {
Write-host "Registry key HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce\NetTCPPortSharing already exists." -ForegroundColor yellow
Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "NetTCPPortSharing" -Value $RunOnceCommand | Out-Null
} else {
New-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "NetTCPPortSharing" -Value $RunOnceCommand -PropertyType "String" | Out-Null
}
}
Import-Module ServerManager
$opt = "None"
# Do {
clear
if ($opt -ne "None") {write-host "Last command: "$opt -foregroundcolor Yellow}
write-host
write-host Exchange Server 2010 - Prerequisites script
write-host Please, select which role you are going to install..
write-host
write-host '1) Hub Transport'
write-host '2) Client Access Server'
write-host '3) Mailbox'
write-host '4) Unified Messaging'
write-host '5) Edge Transport'
write-host '6) Typical (CAS/HUB/Mailbox)'
write-host '7) Client Access and Hub Transport'
write-host
write-host '9) Configure NetTCP Port Sharing service'
write-host ' Required for the Client Access Server role' -foregroundcolor yellow
write-host ' Automatically set for options 2,6, and 7' -foregroundcolor yellow
write-host '10) Install 2007 Office System Converter: Microsoft Filter Pack'
write-host ' Required if installing Hub Transport or Mailbox Server roles' -foregroundcolor yellow
write-host ' Automatically set for options 1, 3, 6, and 7' -foregroundcolor yellow
write-host
write-host '13) Restart the Server'
write-host '14) End'
write-host
$opt = Read-Host "Select an option.. [1-14]? "
switch ($opt) {
1 { InstallFilterPack; Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server -restart }
2 { SetRunOnce; Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy -restart }
3 { InstallFilterPack; Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server -restart }
4 { Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Desktop-Experience -restart }
5 { Add-WindowsFeature NET-Framework,RSAT-ADDS,ADLDS -restart }
6 { SetRunOnce; InstallFilterPack; Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy -restart }
7 { SetRunOnce; InstallFilterPack; Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy -restart }
9 { Set-Service NetTcpPortSharing -StartupType Automatic }
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: http://tinyurl.com/36yrlj'}
}
}
13 { Restart-Computer }
14 {write-host "Exiting..."}
default {write-host "You haven't selected any of the available options. "}
}
# }
# while ($opt -ne 14)
[…] thanks for sharing this with the community. His blog entry with the script can be seen at his blog https://www.bhargavs.com/index.php/powershell/2009/11/script-to-install-exchange-2010-pre-requisites-… and also saved his script on this location: […]
Hi Bhargav,
You rock my friend, nicely done! I blogged about it on my blog and I linked to this post.
Thanks,
Anderson Patricio.
As always…. Awesome !!!!!!!!!!!!
[…] Funky Source: https://www.bhargavs.com/index.php/powershell/2009/11/script-to-install-exchange-2010-pre-requisites-… […]
Just a reminder that after Exchange is installed, you have to register the file types from the FilterPack. See http://technet.microsoft.com/en-us/library/ee732397%28EXCHG.140%29.aspx
[…] or you can get the version that downloads the filter pack from Bhargav […]
The OS test is useless and will block the execution of the script. Because Windows 2008 R2 only exist in 64 bit version.
I have got a 64 bit and i get the value 6.1.7600 in the version field..
Please delete that test form your script
6.1.7600 is also a version for Windows 7 so the script ensures you don’t end up running it accidently on wrong OS. It’s a sanity check preventing you from installing something accidently. Feel free to remove it for your use.
[…] needed for PowerShell v2. So I started with a great script and made it better. My starting point is Bhargav Shukla’s script, which in turn started […]
Nice script! Will post a link to this article on my blog!
Thanks!
WOULD the same script work if it were Server 2008 standard and not R2? I’m hitting a block during my install of Exc2010 SP1, It gets as far as the mailbox Role then says “Error: This server role can not be installed because the following Roles aren’t current: AdminToolsRole.” We initially installed the Exc2010but encountered some public folder issues amoung other. So were now the trying SP1 upgrade. The existing environment was preped already. Domain is 2003 Native mode, 3 Exchange 2003 server exist already this is our first install of Exc2010. Please holla if you have any ideas. Thx much!!
Just a quick note to say that anyone using a localised version like french will need to change the following :
if (-not((Get-WMIObject win32_OperatingSystem).OSArchitecture -eq ’64-bit’)
to
f (-not((Get-WMIObject win32_OperatingSystem).OSArchitecture -eq ’64 bits’)
Notice “64-bit” to “64 bits”.
Other languages, you simply take a look at what is displayed when look at the Properties of the Computer to find what to put in the script. Otherwise it tells you that you are not running a 64 bit OS, which you are 🙂
Cheers.
Matthew
Awesome Script. Worked like a charm and loved the logic used.
Good one!!!!
Web Hosting for PHP and mySQL…
[…]Script to install Exchange 2010 pre-requisites for Windows Server 2008 R2 « Bhargav's IT Playground[…]…
ba-ron…
[…]Script to install Exchange 2010 pre-requisites for Windows Server 2008 R2 « Bhargav's IT Playground[…]…
[…] Even downloads the filter pack for you https://www.bhargavs.com/index.php/2009/11/18/script-to-install-exchange-2010-pre-requisites-for-wind… […]
Nice post i like it!!!!!!
What about “Speech Platform Runtime” and “Unified Communications Managed API 2.0, Core Runtime (64-bit)” for Exchange UM Server?
Cheers……
In addition to Khan’s post on Jan 17, I would suggest adding web-wmi to the add-windowsfeatures. These are not required for the out-of-the-box exchange 2010, but are required for the Exchange 2010 SP1 install.
Nice, Thanks for the saving time.
To be up to date you need also to update the script to install Filter Pack V2 and SP1….needed for New Exchange 2010 with SP1
Thanks,
[…] 4. Run the Genius prerequisites script by Bhargav Shukla (found here https://www.bhargavs.com/index.php/2009/11/18/script-to-install-exchange-2010-pre-requisites-for-wind…) […]
Nice post
u can see also some good post on this website
http://www.trainingtech.net/installation-of-exchange-server-2010-on-windows-server-2008-r2