Use PowerShell to Create SCCM 2012 Site Boundaries

I needed a script to create IPRange Boundaries within SCCM 2012. One of my coworkers suggested that I use a PowerShell CMDLet  to get this done for me.

So I opened the CM2012 console and ran the PowerShell Session from the menu in the upper left corner. Then I ran ‘get-help boundary’ to see what was available.

One of the Cmdlets returned was ‘new-cmboundary’. The script reads each line of a csv file in and parses it for the needed information to construct the Boundaries.

Here is the script I came up with.

To run this script you will need to do three things.

  • Run the SCCM 2012 Console as administrator
  • Open the PowerShell session from the menu in the upper left corner of the SCCM Console.
  • Run this command: Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process

CSV File format:
          BoundaryName,BoundaryType,BoundaryValue

EXAMPLE:
Hyper-V Lab IPRANGE,IPRange,172.2.45.2-172.2.45.254

Command-Line:
CreateBoundaries.ps1 <pathtofile>.csv

This script can actually be used to create all of the boundary types in CM2012. To do so, you would need to change the Boundary type and respective value in your CSV file.

Available boundary types are:

  • IPSubnet (Example corresponding value: “172.2.5.0/24”)
  • ADSite (Example corresponding value: “Default-First-Site-Name”)
  • IPv6Prefix (Example corresponding value: “FE80::/64”)
  • IPRange (Example Corresponding value: “172.2.5.2-172.2.5.254”)

For more information about the commands used in the script, open PowerShell from within the SCCM console and type the following commands:

  • Get-Help Import-CSV
  • Get-Help New-CMBoundary
Advertisements

2 responses to “Use PowerShell to Create SCCM 2012 Site Boundaries

  1. make sure to run the ps1 file from the initial prompt. Do NOT change directories in PowerShell or it will cause it to give the error of “This command cannot be run from the current drive. To run this command you must first connect to a
    Configuration Manager drive.”

Leave a Reply

Please log in using one of these methods to post your comment:

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