Wednesday, January 16, 2013

SCOM 2012 SP1 Prerequisites - The PoSh Way

If like me, you're a System Center consultant and find yourself deploying SCOM/OpsMgr 2012 quite frequently (like once or twice a week), then you will know that acquiring and installing the software prerequisites can be a monotonous task. It's not that they are difficult, just a pain when you have to do it regularly as there are some files to be downloaded from the Microsoft download centre and then a number of Windows Server roles and features to be added too.

The order in which you deploy these prerequisites can also determine the number of additional tasks that you have to carry out to get IIS and .NET framework to work together properly. For these reasons, I wanted to share my quick and easy way of getting these prerequisites installed onto your servers.

This post will serve two purposes. Primarily, it's going to be my own central reference point for when I'm out doing deployments and secondly, it might just serve a useful purpose for others too.


In a Windows environment, if you want to get stuff done quickly and efficiently, then there's no better way in my opinion than to use PowerShell. People that know me, will also probably know that my PowerShell Kung Fu isn't great but that I've promised myself this year to ramp up on it. This post is the start of my New Years resolution and I've included some PowerShell scripts here that will download the relevant prerequisite software and install the roles and features for both Windows Server 2008 and Windows Server 2012 - depending on which O/S you are installing SCOM 2012 SP1 onto.

The Real Credits

Before I go any further, it needs to be noted that the scripts in this blog post are an amalgamated and modified version of the excellent scripts originally posted by Tim McFadden here and Steve Beaumont here. I take no credit for the original code and all I have done is to join the two of them together and add one or two very small changes to suit my own SCOM 2012 SP1 deployments. If you haven't already, then I'd encourage you to take the time to read through Tim and Steve's blog's as they contain loads of valuable information to help you along your way when working with System Center.

SCOM 2012 SP1 Prerequisites

If you are installing SCOM 2012 SP1, then here are the software prerequisites listed on TechNet based on server role:

System Requirements: System Center 2012 SP1 - Operations Manager

As you can see from the link above, some of the server roles only have one or two but with the Web Console role, there are quite a few prerequisites that need to be taken into account. If you were using the GUI to configure and deploy these prerequisites, you can be sure that at some point you'll miss something and have to go back to it once or twice before you get it right.

The Windows Server 2012 Scripts

These scripts are also scoped to each individual SCOM 2012 SP1 role that is deployed onto the Windows Server 2012 Operating System. The main differences though to the Windows Server 2008 prerequisites is that .NET Framework 4.0 can be installed directly using PowerShell in Windows Server 2012 and as such we don't need to download the .NET 4.0 redistributable. This makes integration with IIS easier and therefore less scripting is needed to quickly deploy the prereqs onto Windows Server 2012.

Windows Server 2012 - Management Server Role Only PreReq Script


#This section installs the .NET Prereq for Windows Server 2012#
Import-Module ServerManager
Add-WindowsFeature NET-Framework-Core

Click here to download this PowerShell script as a .PS1 file

Windows Server 2012 - Operations Console Role Only PreReq Script


#This section installs the .NET Prereq for Windows Server 2012#
Import-Module ServerManager
Add-WindowsFeature NET-Framework-Core

#This section will download the Report Viewer Distributable Prereq for Windows Server 2008 or Windows Server 2012 to a folder called C:\SCOM2012SP1Prereqs and will then install it automatically#
$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/E/A/1/EA1BF9E8-D164-4354-8959-F96843DD8F46/ReportViewer.exe'
$object.DownloadFile($RPTurl, "$dwnld\ReportViewer.exe")
Start-Process -FilePath "$dwnld\ReportViewer.exe" -ArgumentList /q -Wait

Click here to download this PowerShell script as a .PS1 file


Windows Server 2012 - Web Console Role Only PreReq Script


#This section installs the .NET and IIS Prereqs for Windows Server 2012#
Import-Module ServerManager
Add-WindowsFeature NET-Framework-Core,AS-HTTP-Activation,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Logging,Web-Request-Monitor,Web-Filtering,Web-Stat-Compression,AS-Web-Support,Web-Metabase,Web-Asp-Net,Web-Windows-Auth –restart


 
Windows Server 2012 - Combined Management Server, Operations Console and Web Console Roles PreReq Script


#This section installs the .NET and IIS Prereqs for Windows Server 2012#
Import-Module ServerManager
Add-WindowsFeature NET-Framework-Core,AS-HTTP-Activation,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Logging,Web-Request-Monitor,Web-Filtering,Web-Stat-Compression,AS-Web-Support,Web-Metabase,Web-Asp-Net,Web-Windows-Auth –restart

#This section will download the Report Viewer Distributable Prereq for Windows Server 2008 or Windows Server 2012 to a folder called C:\SCOM2012SP1Prereqs. Once the file has been downloaded it will automatically install#
$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/E/A/1/EA1BF9E8-D164-4354-8959-F96843DD8F46/ReportViewer.exe'
$object.DownloadFile($RPTurl, "$dwnld\ReportViewer.exe")
Start-Process -FilePath "$dwnld\ReportViewer.exe" -ArgumentList /q -Wait



The Windows Server 2008 Scripts

Although most people will be using the Combined Management Server, Operations Console and Web Console Prereq Script, I'll scope the rest of the scripts here to suit each individual SCOM 2012 SP1 role that's deployed onto Windows Server 2008. The reason for doing this is that the prereq's for each role can vary and obviously we don't want to be installing any more roles or features than we actually have to for a server. 

Windows Server 2008 - Management Server Role Only PreReq Script


#This section will download the .NET Framework 4.0 Redistributable Prereq for the SCOM 2012 SP1 Management Server role on Windows Server 2008 to a folder on the C:\ drive called SCOM2012SP1Prereqs and will then install it automatically #

$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe'
$object.DownloadFile($RPTurl, "$dwnld\dotNetFx40_Full_x86_x64.exe")
Start-Process -FilePath "$dwnld\dotNetFx40_Full_x86_x64.exe" -ArgumentList /q -Wait

Click here to download this PowerShell script as a .PS1 file



Windows Server 2008 - Operations Console Role Only PreReq Script


#This section will download the .NET Framework 4.0 Redistributable Prereq for the SCOM 2012 SP1 Management Server role on Windows Server 2008 to a folder on the C:\ drive called SCOM2012SP1Prereqs and will then install it automatically #

$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe'
$object.DownloadFile($RPTurl, "$dwnld\dotNetFx40_Full_x86_x64.exe")
Start-Process -FilePath "$dwnld\dotNetFx40_Full_x86_x64.exe" -ArgumentList /q -Wait

#This section will download the Report Viewer Distributable Prereq for the SCOM 2012 SP1 Operations Console role on Windows Server 2008 to a folder on the C:\ drive called SCOM2012SP1Prereqs and will then install it automatically #

$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/E/A/1/EA1BF9E8-D164-4354-8959-F96843DD8F46/ReportViewer.exe'
$object.DownloadFile($RPTurl, "$dwnld\ReportViewer.exe")
Start-Process -FilePath "$dwnld\ReportViewer.exe" -ArgumentList /q -Wait


Windows Server 2008 - Web Console Role Only PreReq Script


#This section will install all the Windows Server 2008 Roles and Feature Prereqs for the Web Console Role#
import-module servermanager
Add-WindowsFeature NET-Framework-Core,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Logging,Web-Request-Monitor,Web-Filtering,Web-Stat-Compression,AS-Web-Support,Web-Metabase,Web-Asp-Net,Web-Windows-Auth,AS-HTTP-Activation –restart

#This section will download the .NET Framework 4.0 Redistributable Prereq for Windows Server 2008 to a  folder on the C:\ drive called SCOM2012SP1Prereqs and will then install it automatically#

$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe'
$object.DownloadFile($RPTurl, "$dwnld\dotNetFx40_Full_x86_x64.exe")
Start-Process -FilePath "$dwnld\dotNetFx40_Full_x86_x64.exe" -ArgumentList /q -Wait

#This section will enable the ISAPI and CGI extensions for IIS and .NET 4.0 once the .NET 4.0 redistributable has been installed#
c:\windows\system32\inetsrv\appcmd set config /section:isapiCgiRestriction /[path=`'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll`'].allowed:True


Click here to download this PowerShell script as a .PS1 file


Windows Server 2008 - Combined Management Server, Operations Console and Web Console Roles PreReq Script


#This section will install all the Windows Server 2008 Roles and Feature Prereqs for the Web Console Role#
import-module servermanager
Add-WindowsFeature NET-Framework-Core,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Logging,Web-Request-Monitor,Web-Filtering,Web-Stat-Compression,AS-Web-Support,Web-Metabase,Web-Asp-Net,Web-Windows-Auth,AS-HTTP-Activation –restart

#This section will download the Report Viewer Distributable Prereq for the SCOM 2012 SP1 Operations Console role on Windows Server 2008 to a folder on the C:\ drive called SCOM2012SP1Prereqs and will then install it automatically #

$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/E/A/1/EA1BF9E8-D164-4354-8959-F96843DD8F46/ReportViewer.exe'
$object.DownloadFile($RPTurl, "$dwnld\ReportViewer.exe")
Start-Process -FilePath "$dwnld\ReportViewer.exe" -ArgumentList /q -Wait

#This section will download the .NET Framework 4.0 Redistributable Prereq for Windows Server 2008 to a  folder on the C:\ drive called SCOM2012SP1Prereqs and will then install it automatically#

$dwnld = "C:\SCOM2012SP1Prereqs"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory
 }
$object = New-Object Net.WebClient
$RPTurl = 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe'
$object.DownloadFile($RPTurl, "$dwnld\dotNetFx40_Full_x86_x64.exe")
Start-Process -FilePath "$dwnld\dotNetFx40_Full_x86_x64.exe" -ArgumentList /q -Wait

#This section will enable the ISAPI and CGI extensions for IIS and .NET 4.0 once the .NET 4.0 redistributable has been installed#
c:\windows\system32\inetsrv\appcmd set config /section:isapiCgiRestriction /[path=`'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll`'].allowed:True


The updated script can be downloaded from my GitHub repo here:




Conclusion

Using the scripts above, you should be able to now deploy the prerequisites for SCOM 2012 SP1 in no time and maybe even utilise them as part of an automated service deployment in conjunction with SCVMM and Orchestrator - enjoy!

1 comment: