ConfigMgr Script: IP Subnet Boundary Management using CSV

Attached to this post is a PowerShell script that will take a CSV file and manage your boundaries. The script will create new boundaries and delete old ones, all based on a CSV file. This is really nice if you can pull an extract from your network that lists all of the IP Subnets.

Requirements

First, rename the downloaded file with a .ps1 extension.

The script requires at a minimum ConfigMgr 2012 SP2 or R2 SP1 (Current Branch recommended) and must be executed from a  device that has the ConfigMgr console installed. Change the variables in line 2, 5, 8, and 11 to fit your environment. The variable in line 8 asks for a log file location. This script will log all successes and failures to this file.

Line 11 asks for the network extract. At a minimum, this file should contain three columns. One should be whether this is an add or delete, two should be IP subnet, and the third should be a description. Details are provided later in this post about the formatting for these columns.

Required Script Changes

Since there isn’t a common format, you may need to change a few things. Pay attention to these changes.

Lines 20-22:

capture

These are only needed if your CSV file includes the bit length, i.e. the address is formatted like 10.0.0.0/16 instead of just 10.0.0.0. Because ConfigMgr does not need this information (and the command actually errors if it’s included), these lines remove the bit length and reinsert it into the networks variable. If you use this section of the script, be sure that “name” is the column title in your CSV. If it’s not, change the three mentions of “name” in line 22 to reflect the column name that stores the IP information.

Lines 41 and 64:

capture
capture

First, if the column name is not “TYPE”, then change both instances of the type. This is the column that specifies whether this is a new subnet, or a subnet to be removed. Next, if the values aren’t “Add” and “Delete”, change those values accordingly as well.

Lines 45-46 and 68-69:

capture
capture

These are more column heading changes. Be sure that the IP Subnet is the “NAME” column, or change lines 45 and 68 accordingly. Also, make sure the description is in the “C_NAME” column, or change the lines 46 and 69 accordingly.

Disclaimer

All content provided on this blog is for information purposes only. Windows Management Experts, Inc makes no representation as to accuracy or completeness of any information on this site. Windows Management Experts, Inc will not be liable for any errors or omission in this information nor for the availability of this information. It is highly recommended that you consult one of our technical consultants, should you need any further assistance.

[download id=”5460″]

Share:

Facebook
Twitter
LinkedIn

Contact Us

=
On Key

More Posts

Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.

=