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

WME Cybersecurity Briefings No. 005
Cyber Security

WME Security Briefing 15 April 2024

E-Commerce Security Alert: Unveiling Magecart’s Persistent Backdoor Overview Malicious activities by Magecart attackers have been reported. They are targeting Shopify’s content delivery network (CDN) by creating fake Shopify stores. The backdoor method has enabled them to

Read More »
WME Cybersecurity Briefings No. 004
Cyber Security

WME Security Briefing 11 April 2024

Mispadu Trojan Exploits Windows Vulnerability to Target Financial Data Overview The Mispadu banking trojan has intensified its operations as it’s exploiting an already patched Windows SmartScreen flaw. Since its initial identification in 2019, Mispadu has primarily preyed on

Read More »
WME Cybersecurity Briefings No. 003
Cyber Security

WME Security Briefing 29 March 2024

Russian hackers escalating their cyber warfare, deploying TinyTurla-NG to breach European NGOs. Cisco Talos reveals a targeted attack against organizations advocating democracy and supporting Ukraine. With their sophisticated methods, these cyber attackers are bypassing antivirus defenses

Read More »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.

=