Powershell : OpsMgr : SCOM 2012 Prereqs Powershell



Start-Transcript -Path c:transcript0.txt -noclobber

# This scripts needs unrestricted access
Write-Host "This scripts needs unrestricted access (Set-ExecutionPolicy Unrestricted.)" -ForegroundColor Green
Write-Host "The prereq setup for System Center 2012 R2 Operations Manager takes around 15 minutes depending on your internet speed" -ForegroundColor Green

# Setting the variables.
$folderpath0 = 'C:Source'
$ShareName = "Source$"

#Check if folder exists, if not, create it
if (Test-Path $folderpath0){
Write-Host "The folder $folderPath0 exists."
} else{
Write-Host "The folder $folderPath0 does not exist, creating..." -NoNewline
New-Item $folderpath0 -type directory | Out-Null
Write-Host "done!" -ForegroundColor Green
}

# Check if file exists, if not, download it
$file0 = $folderPath0+"SQLSysClrTypes.msi"
$file1 = $folderPath0+"Reportviewer.msi"

if (Test-Path $file0){
write-host "The file $file0 exists."
} else {

# Download System CLR Types for SQL Server 2012
Write-Host "System CLR Types for SQL Server 2012" -nonewline -ForegroundColor yellow
$clnt = New-Object System.Net.WebClient
$clnt.DownloadFile($url,$file0)
Write-Host "done!" -ForegroundColor Green

}

if (Test-Path $file1){
write-host "The file $file1 exists."
} else {

# Download Microsoft Report Viewer 2012 Runtime
Write-Host "Microsoft Report Viewer 2012 Runtime" -nonewline -ForegroundColor yellow
$clnt = New-Object System.Net.WebClient
$clnt.DownloadFile($url,$file1)
Write-Host "done!" -ForegroundColor Green

}

# Install Windows Features.
Get-Module servermanager
Install-WindowsFeature -Name Web-Server
Install-WindowsFeature -Name Web-Default-Doc
Install-WindowsFeature -Name Web-Dir-Browsing
Install-WindowsFeature -Name Web-HTTP-Errors
Install-WindowsFeature -Name Web-Static-Content
Install-WindowsFeature -Name Web-Http-Logging
Install-WindowsFeature -Name Web-Request-Monitor
Install-WindowsFeature -Name Web-Stat-Compression
Install-WindowsFeature -Name Web-Filtering
Install-WindowsFeature -Name Web-Windows-Auth
Install-WindowsFeature -Name Web-Net-Ext
Install-WindowsFeature -Name Web-Net-Ext45
Install-WindowsFeature -Name Web-Asp-Net
Install-WindowsFeature -Name Web-ISAPI-Ext
Install-WindowsFeature -Name Web-ISAPI-Filter
Install-WindowsFeature -Name Web-Mgmt-Console
Install-WindowsFeature -Name Web-Metabase
Install-WindowsFeature -Name NET-Framework-Core
Install-WindowsFeature -Name NET-HTTP-Activation
Install-WindowsFeature -Name NET-WCF-HTTP-Activation45
Install-WindowsFeature -Name Windows-Identity-Foundation
Install-WindowsFeature -Name Telnet-Client

# Install System CLR Types for SQL Server 2012
Write-Host "Installing System CLR Types for SQL Server 2012.." -nonewline

$PSScriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path

msiexec /qb /i "$folderPath0SQLSysClrTypes.msi" | Out-Null

Write-Host "done!" -ForegroundColor Green
Start-Sleep -s 10

# Install Microsoft Report Viewer 2012 Runtime
Write-Host "Microsoft Report Viewer 2012 Runtime.." -nonewline

$PSScriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path

msiexec /qb /i "$folderPath0ReportViewer.msi" | Out-Null

Write-Host "done!" -ForegroundColor Green
Start-Sleep -s 10

Write-Host "The server needs to be restarted before you start the System Center 2012 R2 Operations Manager installation." -nonewline -BackgroundColor Black -ForegroundColor Red


Stop-Transcript

Comments

Popular posts from this blog