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

Mastering Azure AD Connect - A Comprehensive Guide by WME
Active Directory

Mastering Azure AD Connect – A Comprehensive Guide

Modern businesses are fast moving toward cloud-based infrastructure. In fact, cloud-based business is not just a trend anymore but a strategic necessity. Microsoft’s Azure Active Directory (Azure AD) has become a frontrunner in this domain. It

Read More »
Security Best Practices in SharePoint
Office 365

Security Best Practices in SharePoint

Microsoft SharePoint is an online collaboration platform that integrates with Microsoft Office. You can use it to store, organize, share, and access information online. SharePoint enables collaboration and content management and ultimately allows your teams to

Read More »
The Ultimate Guide to Microsoft Intune - Article by WME
Active Directory

The Ultimate Guide to Microsoft Intune

The corporate world is evolving fast. And with that, mobile devices are spreading everywhere. As we venture into the year 2024, they have already claimed a substantial 55% share of the total corporate device ecosystem. You

Read More »
Protecting Microsoft 365 from on-Premises Attacks
Cloud Security

How to Protect Microsoft 365 from On-Premises Attacks?

Microsoft 365 is diverse enough to enrich the capabilities of many types of private businesses. It complements users, applications, networks, devices, and whatnot. However, Microsoft 365 cybersecurity is often compromised and there are countless ways that

Read More »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.