HOWTO: install a primary site server and prerequisites using commandline / Powershell

Posted: February 10, 2014 in Uncategorized

Hi, every once and a while i need a site server to test or demo some functions. Each time however, I need to spend a day to deploy a server and download/install SCCM, SQL, ADK, server roles, preqeqs and more by hand. Not having to wait for each step to finish i wrote a basic powershell script to automate this. It doesn’t use variables or fancy loops, just batching it all up in one script.

Step 1: Download source files
Having a fresh installed Windows Server 2012 which is a domain member copy all required files to this server to a folder named: C:\Sources. You will need to (pre-)download all files and place them in the following folders:

  • ADK 8.1: C:\Sources\ADK8.1
  • SCCM 2012 R2 setup: C:\Sources\SCCM2012R2
  • SCCM 2012 prereqs: C:\Sources\SCCM2012R2\Downloads
  • SQL 2012 SP1: C:\Sources\SQL2012SP1
  • SQL 2012 SP1 Cumulative Update 2: C:\Sources\SQL2012CU2
  • Windows Server 2012 Feature file store: C:\Sources\SxS

Note that for ADK as well as SCCM 2012 prereq files you will need to pre-download the sources by running the setup wizard.

Step 2: Create unattended setup ini for ConfigMgr
The setup executable for ConfigMgr supports an input file. The following example is a minimal set of required input parameters for the setup to install unattended:

[Identification]
Action=InstallPrimarySite
[Options]
ProductID=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
PrerequisiteComp=0
PrerequisitePath=C:\Sources\SCCM2012R2\Downloads
SiteCode=HQ1
SiteName="DvdRuit HQ"
SMSInstallDir="c:\program files\ConfigMgr"
ManagementPoint=S01.DVDRUIT.LOCAL
ManagementPointProtocol=HTTP
SDKServer=S01.DVDRUIT.LOCAL
RoleCommunicationProtocol=HTTPorHTTPS
ClientsUsePKICertificate=0
DistributionPoint=S01.DVDRUIT.LOCAL
DistributionPointProtocol=HTTP
DistributionPointInstallIIS=0
MobileDeviceLanguage=0
[SQLConfigOptions]
SQLServerName=S01.DVDRUIT.LOCAL
DatabaseName=SMS_HQ1
SQLSSBPort=4022

You might need to modify some these parameters to match your environment. You will need a valid product key. Evaluation version does not support unattended installation (unfortunately). Save this file to C:\Sources\Site-setup.ini.

Step 3: Create a powershell (batch) script to install all prerequisites one by one
To install all prereqs you will have to start of by extending the AD schema with some attributes that are used by ConfigMgr. I’ve put this at the top to make sure that replication to other domain controllers is done once the SCCM setup command is called. A summary of what is installed:

  • Extend AD
  • Install Windows Features
  • Install ADK 8.1
  • Create SQL service account
  • Install SQL 2012 SP1 with CU2
  • Install ConfigMgr R2

Behold the powershell script:

echo =======================================================================
echo ======== INSTALL SITE SERVER AND PREREQS SCRIPT =========
echo ======== By: Douwe van de Ruit =========
echo =======================================================================
echo Before proceeding make sure to copy sources from ADK, SQL 2012 SP1,
echo SQL 2012 CU2, Windows 2012 sxs and ConfigMgr R2 echo to
echo C:\Sources\ADK, C:\Sources\SCCM2012R2, C:\Sources\SQL2012SP1,
echo C:\Sources\SQL2012CU2 and C:\Sources\sxs. Pre-download all prereq
echo files for ConfigMgr to C:\Sources\SCCM2012R2\Downloads. Tested on Hyper-V.
echo No reboots required. Hit enter, get some coffee, sit back and enjoy the ride.
pause
#schema extension
C:\Sources\SCCM2012R2\SMSSETUP\BIN\X64\extadsch.exe
#server prereqs
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-WindowsFeature WDS
dism /online /enable-feature /featurename:NetFX3 /all /Source:c:\sources\sxs /LimitAccess
#install adk components
cmd /c C:\Sources\ADK8.1\adksetup.exe /quiet /installpath 'C:\Program Files (x86)\Windows Kits\8.1' /features OptionId.DeploymentTools OptionId.WindowsPreinstallationEnvironment OptionId.UserStateMigrationTool
#install sql db
New-ADUser -SamAccountName svcSQL -AccountPassword (ConvertTo-SecureString -AsPlainText "P@ssw0rd" -Force) -name "svcSQL" -enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false
Enable-ADAccount svcSQL
C:\Sources\SQL2012SP1\Setup.exe /qs /ACTION=Install /UpdateEnabled=TRUE /UpdateSource="C:\Sources\SQL2012CU2\" /FEATURES=SQL,RS,Tools /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT="DVDRUIT\svcSQL" /SQLSVCPASSWORD="P@ssw0rd" /SQLSYSADMINACCOUNTS="DVDRUIT\Domain Admins" /AGTSVCACCOUNT="NT AUTHORITY\Network Service" /IACCEPTSQLSERVERLICENSETERMS /SQLCOLLATION=SQL_Latin1_General_CP1_CI_AS 
#install configMgr
C:\Sources\SCCM2012R2\SMSSETUP\BIN\X64\setup.exe /script C:\Sources\Site-setup.ini /nouserinput

There you go! A simple but handy script to automate the installation of a SCCM Site server. Copy this to “C:\Sources\Install-Site server.ps1”. You might need to change some parameters. Run the script with administrative permissions. When you open the taskmgr and see this you’ll be good:

task mgr

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I hope this may be of some assistance! After a while SCCM is installed. 🙂

SCCM installed

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s