SCCM 2012 R2 Prerequisites Powershell Installer.

Why do it manually when you can have Powershell do it for you…..

You know the felling when you think you are done with all the prerequisites and you start the installation. And BOOOM the installation stops because you are missing a prereq.
If you use Powershell to install the prereq you wont miss any of the prerequisites next time you are going to install SCCM 2012 R2.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# ***************************************************************************
# 
# Author:    Chris Steding 2014-04-10
# 
# Purpose:   This PowerShell script will install all prereq for SCCM 2012 R2
#     
#
#  * Change the variable for the folderpath if needed.      
#
#
#
# ------------- DISCLAIMER --------------------------------------------------
# This script code is provided as is with no guarantee or warranty concerning
# the usability or impact on systems.
# ------------- DISCLAIMER --------------------------------------------------
#
# **************************************************************************
 
# This scripts needs unrestricted access 
Write-Host "This scripts needs unrestricted access (Set-ExecutionPolicy Unrestricted.)</code><code>" -ForegroundColor Green
Write-Host "The prereq setup for SCCM 2012 R2 takes around 15 minutes depending on your internet speed" -ForegroundColor Green
 
# Setting the variables.
 $folderpath0 = 'D:\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
 }
 
 # Sharing the Source folder
$Type = 0
$objWMI = [wmiClass] 'Win32_share'
$objWMI.create($folderpath0, $ShareName, $Type)
 
# Check if file exists, if not, download it
 $file0 = $folderPath0+"\adksetup.exe"
 $file1 = $folderPath0+"\MicrosoftDeploymentToolkit2013_x64.msi"
 
 if (Test-Path $file0){
 write-host "The file $file0 exists."
 } else {
 
#Download Windows Assessment and Deployment Kit (ADK) 8.1
		Write-Host "Downloading Windows Assessment and Deployment Kit (ADK) 8.1.." -nonewline -ForegroundColor yellow
		$clnt = New-Object System.Net.WebClient
		$url = "http://download.microsoft.com/download/6/A/E/6AEA92B0-A412-4622-983E-5B305D2EBE56/adk/adksetup.exe"
		$clnt.DownloadFile($url,$file0)
		Write-Host "done!" -ForegroundColor Green
 }
 
 if (Test-Path $file1){
 write-host "The file $file1 exists."
 } else {
 
# Download Microsoft Deployment Toolkit 2013 
		Write-Host "Downloading Microsoft Deployment Toolkit 2013.." -nonewline -ForegroundColor yellow
		$clnt = New-Object System.Net.WebClient
		$url = "http://download.microsoft.com/download/B/F/5/BF5DF779-ED74-4BEC-A07E-9EB25694C6BB/MicrosoftDeploymentToolkit2013_x64.msi"
		$clnt.DownloadFile($url,$file1)
		Write-Host "done!" -ForegroundColor Green
 
 }
 
# Install Windows Features.
Get-Module servermanager
Install-WindowsFeature Web-Windows-Auth
Install-WindowsFeature Web-ISAPI-Ext
Install-WindowsFeature Web-Metabase
Install-WindowsFeature Web-WMI
Install-WindowsFeature BITS
Install-WindowsFeature RDC
Install-WindowsFeature NET-Framework-Features
Install-WindowsFeature Web-Asp-Net
Install-WindowsFeature Web-Asp-Net45
Install-WindowsFeature NET-HTTP-Activation
Install-WindowsFeature NET-Non-HTTP-Activ
 
# Install ADK: Deployment Tools and Windows Preinstallation Enviroment.
 
Write-Host "Installing ADK 8.1 this might take a few minutes.." -nonewline -ForegroundColor yellow
 
Start-Process -FilePath "$folderPath0\adksetup.exe" -Wait -ArgumentList "/quiet /norestart /ceip off /features OptionId.DeploymentTools OptionId.WindowsPreinstallationEnvironment"
 
Write-Host "done!" -ForegroundColor Green
Start-Sleep -s 20
 
# Create no_sms_on_drive.sms on the C drive.
 
Write-host "Creating no_sms_on_drive.sms on the C drive...." -NoNewline -ForegroundColor yellow
New-Item c:\no_sms_on_drive.sms -type file
 
Write-Host "done!" -ForegroundColor Green
 
# Creating the Source folder structure
 
Write-host "Creating Source folders..." -NoNewline -ForegroundColor Yellow
New-Item $folderpath0\Microsoft\_AppName-v1.1.2 -type directory
New-Item $folderpath0\Adobe\_AppName-v1.1.2 -type directory
New-Item $folderpath0\SUN\_AppName-v1.1.2 -type directory
Write-Host "done!" -ForegroundColor Green
 
Write-Host "The server needs to be restarted before you start the SCCM 2012 R2 installation!" -nonewline -BackgroundColor Black -ForegroundColor Red

Download the script as a ZIP file.
http://www.compit.se/download/script/SCCM-2012-prereq-install.zip

// Chris Steding

 

 

 

 

 

This entry was posted in Deployment, Scripting and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *