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
The link to the script doesn’t work anymore.
LikeLike
The powershell link does’t work any more. please update the link.
LikeLike
Link no longer works
LikeLike
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.”
LikeLike
Good point, I’ll update the blog when I get a chance later.
LikeLike