Automating IP Subnet Site Boundaries in Configuration Manager Current Branch

There are a lot of great scripts out there for automating the creation of site boundaries in Configuration Manager, as well as some fantastic articles describing boundaries and boundary groups in great depth.  You can check out one of these articles here at Windows-Noob that gets into a very detailed description of Active Directory site boundaries, and also includes a great Power Shell script for creating them.

In this post, I am going to cover automating the creation of IP subnet site boundaries and boundary groups.  With the help of a coworker of mine, (The one who actually made the script work, and who you can find here on Twitter @cweberits.) we put together a Power Shell script that will read into a CSV file, create IP subnet boundaries, boundary groups, and will assign site servers to the associated boundary groups. (Edit: We are working on a version that will do a check to see if the boundary already exists, and it will be posted when it is available.)

I find using active directory boundaries to be the best method due to the fact that you allow the IP subnets to be managed in a central location (AD) and they are easily imported and maintained.  The caveat to that being that “Active Directory Sites and Subnets” has to be maintained.  In my experiences, I find this is most often not the case.  Leaving us to use either IP subnets or IP ranges.  IP ranges aren’t optimal due to the large amount of SQL processing that is used to evaluate the boundary members as opposed to an IP subnet.

To use this script, you need to create a CSV file.  The format of the CSV has to be as follows:
(e.g. – Boundary1,IPSubnet,,Group1,cm1.its.lab)

#Define the CSV file name and location

$CSVFile = “C:\test.csv”

#Import the ConfigMgr PowerShell module & witch to ConfigMgr
$snip = $env:SMS_ADMIN_UI_PATH.Length-5
$modPath = $env:SMS_ADMIN_UI_PATH.Substring(0,$snip)
Import-Module “$modPath\ConfigurationManager.psd1”
$SiteCode = Get-PSDrive -PSProvider CMSite
Set-Location “$($SiteCode.Name):\”

#Import the CSV file and create content
Import-CSV $CSVFile -Header Name,Type,Value,Group,Server | Foreach-Object {
  New-CMBoundaryGroup -Name $_.Group
New-CMBoundary -Name $_.Name -Type $_.Type -Value $_.Value
Add-CMBoundaryToGroup -BoundaryName $_.Name -BoundaryGroupName $_.Group
Set-CMDistributionPoint -sitecode ITS -SiteSystemServerName $_.Server -AddBoundaryGroupName $_.Group

# This is the format the the CSV file needs to be in.
# Boundary1,IPSubnet,,Group1,cm1.its.lab
# Boundary2,IPSubnet,,Group2,cm2.its.lab
# Boundary3,IPSubnet,,Group3,cm3.its.lab
# Boundary4,IPSubnet,,Group4,cm4.its.lab
# Boundary5,IPSubnet,,Group5,cm5.its.lab

To verify that the script completed with no errors, we can monitor SMSProv.log to see the boundaries, and boundary groups get created, as well as site server assignments.


Leave a Reply

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

You are commenting using your 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