Automating SMS 2003 Secondary Site installations

I've been a bit quiet lately on my blog. I regret it, but I hope to come back with some good content in the following weeks.

What I found out with SMS 2003 production deployments is that especially with very dispersed network structures, you might end up with a very large number of secondary sites. That is because installing a secondary site is one of the best ways to control bandwith usage between remote location and your head office. So without automating that procedure you might end up spending days clicking through the SMS 2003 admin console, which unfortunately is far from user-friendly.

I have created a bunch of scripts, and hope to here I post the approach and some snippets.

Secondary Site installation steps overview:

1. Install IIS and configure to facilitate BITS for Distribution Points

First of all you should make sure that all your servers have current and updated pointers to where you store your Windows binaries (you need to point to the folder where the i386 folder of Windows CD can be found):

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
"SourcePath"="D:\\Install"
"ServicePackSourcePath"="D:\\Install"

When this is done you can use sysocmgr.exe to install IIS with options necessary for SMS (https://support.microsoft.com/kb/309506).

I found this answer file did the job for me:

[Components]
aspnet = off
complusnetwork = on
dtcnetwork = off
bitsserverextensionsisapi = on
bitsserverextensionsmanager = on
iis_common = on
iis_ftp = off
fp_extensions = off
iis_inetmgr = on
iis_nntp = off
iis_smtp = off
iis_asp = off
iis_internetdataconnector = off
sakit_web = off
tswebclient = off
iis_serversideincludes = off
iis_webdav = on
iis_www = on
appsrv_console = off
inetpring = off

The script I use is basically a simple batch:

sysocmgr /i:sysoc.inf /u:d:\install\sms2k3\IIS60config.txt /q /r

Finally I add urlscan 2.5 SMS template file from SMS Toolkit 2 to secure the IIS on the site servers:

d:\install\sms2k3\URLScan\urlscan.exe /q

I actually run it twice: first run it from a share to install urlscan 2.5, then copy the urlscan.ini file from the toolkit to %windows%\system32\inetsrv\urlscan\ (https://www.microsoft.com/technet/prodtechnol/sms/sms2003/downloads/tools/toolkit.mspx)

Then I run it locally second time to make sure the ini file is read into the urlscan.dll.

2. Automate Secondary Site installation

This step I have not yet automated, due to the fact that at this time the SMS 2003 SP3 slipstreamed CD is not yet available, I would have to install SP2 version then upgrade. But this is possible with the use of the answer file to the SMS setup binaries (https://support.microsoft.com/kb/273734) or through Create Secondary Site Tool from SMS Toolki 2.

3. Transfer site settings

For that step I use the SMS 2003 Transfer Site settings wizard from SMS 2003 SP1 Administration Feature Pack. Unfortunately I found out that saving the config file and rerunning it from UI fails for SMS 2003 SP3 sites. You may be able to run this using command line tool: replsitecnfg.exe, however I run it from UI importing settings from 1 secondary site and mass updating remaining all sites.

4. Transfer site accounts

I use msac.exe (managesiteaccounts tool from the SMS SP1 admin pack). I found a bug, which was fixed by MS (https://support.microsoft.com/kb/920108), so its worth using the msac.exe version from the KB article and not the SMS 2003 SP1 admin pack.

The syntax is pretty simple and documented, I usually delete accounts and then create them (after giving SMS some time to process deletion ~3min, e.g. sleep 180 in batch script)

5. Assign site boundaries

To assign site boundaries I use vbscript that reads from a text file list. The main part of the script is:

sRelPath = "SMS_SCI_SiteAssignment.FileType=2,ItemName=""Site Assignment"",ItemType=""Site Assignment"",SiteCode=""" & gsSiteCode & """"
Dim oSCI_SiteAssign
Set oSCI_SiteAssign = goWMIConnection.Get(sRelPath,, goWMIContext)

' Save the changes to the SCI
oSCI_SiteAssign.AssignDetails = astrBoundaryPart(0) 'Subnet or AD Site name
oSCI_SiteAssign.AssignTypes = astrBoundaryPart(1) 'IP Subnet or AD Site

oSCI_SiteAssign.Put_ ,goWMIContext

' Commit the SCF changes

6. Configure site systems

To configure a default MP and a protected DP with bits enabled I use vbscript. The main part of script is:

Set oNewInst = goWMIConnection.Get("SMS_SCI_SysResUse").SpawnInstance_
'assign server as an MP
oNewInst.Sitecode = strSiteCode
oNewInst.RoleName = "SMS Management Point"
oNewInst.NetworkOSPath = "\\" & strSiteServer
oNewInst.NALType = "Windows NT Server"
oNewInst.NALPath = "[""Display=\\" & strSiteServer & "\""]MSWNET:[""SMS_SITE=" & strSiteCode & """]\\" & strSiteServer & "\"
oNewInst.ItemType = "System Resource Usage"
oNewInst.ItemName = "[""Display=\\" & strSiteServer & "\""]MSWNET:[""SMS_SITE=" & strSiteCode & """]\\" & strSiteServer & "\,SMS Management Point"

'save, commit changes to site control file
oNewInst.Put_ , goWMIContext
CommitSCF strSiteCode

' Add the default properties
Set Prop1=goWMIConnection.Get("SMS_EmbeddedProperty").Spawninstance_()
Prop1.PropertyName="MPDefault"
Prop1.Value=1
Set Prop2=goWMIConnection.Get("SMS_EmbeddedProperty").Spawninstance_()
Prop2.PropertyName="UseSiteDatabase"
Prop2.Value=1
oNewInst.Props = Array(Prop1,Prop2)

'save, commit SCF
oNewInst.Put_ , goWMIContext
CommitSCF strSiteCode

' Add the default properties
Set Prop1=goWMIConnection.Get("SMS_EmbeddedProperty").Spawninstance_()
Prop1.PropertyName="MPDefault"
Prop1.Value=0
Set Prop2=goWMIConnection.Get("SMS_EmbeddedProperty").Spawninstance_()
Prop2.PropertyName="MPType"
Prop2.Value=1
oNewInst.Props = Array(Prop1,Prop2)

'save, commit SCF
oNewInst.Put_ , goWMIContext
CommitSCF strSiteCode

'assign server as DP
Set oNewInst = goWMIConnection.Get("SMS_SCI_SysResUse").SpawnInstance_
oNewInst.Sitecode = strSiteCode
oNewInst.RoleName = "SMS Distribution Point"
oNewInst.NetworkOSPath = "\\" & strSiteServer
oNewInst.NALType = "Windows NT Server"
oNewInst.NALPath = "[""Display=\\" & strSiteServer & "\""]MSWNET:[""SMS_SITE=" & strSiteCode & """]\\" & strSiteServer & "\"
oNewInst.ItemType = "System Resource Usage"
oNewInst.ItemName = "[""Display=\\" & strSiteServer & "\""]MSWNET:[""SMS_SITE=" & strSiteCode & """]\\" & strSiteServer & "\,SMS Distribution Point"

'save, commit SCF
oNewInst.Put_ , goWMIContext
CommitSCF strSiteCode

' Add the default properties
Set Prop1 = goWMIConnection.Get("SMS_EmbeddedProperty").SpawnInstance_
Prop1.PropertyName = "IsProtected"
Prop1.Value = 1
Set Prop2 = goWMIConnection.Get("SMS_EmbeddedProperty").SpawnInstance_
Prop2.PropertyName = "BITS download"
Prop2.Value = 1
Set Prop3 = goWMIConnection.Get("SMS_EmbeddedPropertyList").Spawninstance_()
Prop3.PropertyListName = "Protected Boundary"
Prop3.Values = Array(astrBoundaryPart(1),astrBoundaryPart(0))
oNewInst.Props = Array(Prop1,Prop2)
oNewInst.PropLists = Array(Prop3)

'save, commit SCF

 

Both scripts for 5 and 6 read from files that have each row in format:

Subnet/ADsitename,IP Subnets/AD Site,SITECODE,SITESERVERNAME

Of course those are just parts of the code, which are built around functions that commit the SCF, connect to WMI and read from the text file. If I get time to package those scripts I will post them for your reference, but they still will need decent testing, as there is not much error handling.

Comments