Continue to site Õ
Welcome to
Home
Newsletters
White Papers
Webcasts
Advertise
Contact Us
Desktop
Server
Cloud
PowerShell
Security
More
Tweet
Share
PowerShell How-To
Use PowerShell To Create a Free IPAM Solution You can buy a third-party tool or service. Or you can do it for free in in PowerShell. By Adam Bertram
Continue to site Õ
04/02/2015
IP address management (IPAM) is a concept that can be implemented in many ways. At its core, IPAM is simply a way to keep track of all the IP addresses in a business environment. Services such as Dynamic Host Configuration Protocol (DHCP) make this process a lot simpler -- but you'll rarely see a business track all of its IP addresses from DHCP alone. Even so, large businesses may have hundreds, if not thousands, of DHCP scopes to worry about. Even if DHCP is handing out IP addresses automatically, managing all of those scopes soon becomes a nightmare. What medium- to large-sized businesses need is an IPAM solution. A good IPAM solution is one that enables a user to quickly query some kind of data repository (for example, a database, an Excel spreadsheet, or a CSV) to find, create and modify information about a particular IP address. IPAM solutions enable you to store more than just the IP address. You can also store information -- such as the hostname the IP is currently assigned to, the location of the host and the switch port the host is plugged into -- among other things. Storing this information enables the user to easily find all IP addresses in use at a particular location, locate any IP addresses that are free to use if needed for assigning to a new server, and so on.
There are numerous commercial solutions that set out to solve the IPAM problem. Solutions such as SolarWinds IP Address Management, Men and Mice IP Address Management Module, and GestióIP's IP Address Management Software are just a few I could quickly see were available. I'm sure all of these products do a fine job, but they've got one thing in common I'm not looking for -- they aren't free! Being commercial products, they all have a price. On the flip side, I have seen several open source IPAM tools that are free, but they aren't easily customizable and they're overkill for what I need. I'm simply looking for some kind of small repository where I can store, perhaps, a few thousand IP addresses and common information about them -- such as associated hostname, whether or not the IP is in a DHCP scope, and the location. I need a solution that's easily customizable, so I can add another attribute later on down the road if needed. Finally, I want a solution that's easily accessible from all of my IT personnel's desktops and requires no specific software. I've got an idea -- PowerShell! Using a PowerShell module, I can easily create functions to solve simple IPAM problems like I just described. The module I've created also doesn't involve any complicated databases or clients. The only things you need are PowerShell, the imported module and a willing staff. This IPAM solution was designed to be as simple yet as functional as possible. This is why I've chosen to use a single shared CSV file to store all of the IP address data. Granted, this approach does not handle multiple edits at the same time, and you may run into an issue if this module is used by dozens of people at once. If you've got that much need, I recommend purchasing a commercial solution. If not, this module works great as a poor man's IPAM product. Without further ado, let's jump into our module, called IPAddressManagement, and the steps you'll need to take to implement it. Step 1: Download the module and place it in a shared network location where you and your team can access it. Step 2: Create the CSV file used to store your IP addresses. Ensure the file is in a shared network location with at least a column called IPAddress. I also recommend creating a column called SubnetMask. The other attributes you'd like to assign to the IP are optional. Step 3: Modify the module's code on line 1 to reflect the actual location of the CSV file. Step 4: Import the module in each team member's PowerShell profile. Step 5: Start adding IPs into your new IPAM solution! Let's go over these steps quickly in a short tutorial. The first step in using this module is to add some IPs into it. The following figure is a good example. It shows us adding the IP address 192.168.1.2 with a subnet mask of 255.255.255.0 for a server named MYSERVER in the location of Rome. This will work assuming you've created IPAddress, SubnetMask, Hostname, and Location fields in your CSV. The necessary functions will automatically create the field parameters you need by using dynamic parameters.
[Click on image for larger view.]
Once you've got some IP addresses in your CSV file, a common task I've seen is figuring out an available static IP address to assign to a new server. For this reason, I created the Get-FreeIPAddress function. This function ping sweeps a particular network searching for IP addresses that don't respond to a ping. If they don't, this function will output those IP addresses. If you'd like, you can also combine this function and the New-IpAddress function to both find and record your IP addresses into the CSV file.
[Click on image for larger view.]
You can also modify existing IP addresses with Set-IpAddress and remove IP addresses with Remove-IpAddress using similar methods. This IPAM module is just the start. If enough work is put into it, this module could evolve into a feature-rich solution! Think about pulling in all of your DHCP scopes across all servers into your CSV -- or even scripting new server installs to assign themselves an IP address automatically using this module! I'd love to hear about any new additions you add to it. Get in touch with me on Twitter @adbertram!
About the Author Adam Bertram is an independent consultant, technical writer, trainer and presenter. Adam specializes in consulting and evangelizing all things IT automation mainly focused around Windows PowerShell. Adam is a Microsoft Windows PowerShell MVP, 2015 powershell.org PowerShell hero and has numerous Microsoft IT pro certifications. He is a writer, trainer and presenter and authors IT pro course content for Pluralsight. He is also a regular contributor to numerous print and online publications and presents at various user groups and conferences. You can find Adam at adamtheautomator.com or on Twitter at @adbertram.
PRINTABLE FORMAT
Recommended: Newest Ransomware Strains and Mitigation Strategies 3 Comments
Microsoft Certified Professional Magazine
Recommend
1
Login
Sort by Best
Share
Join the discussion… Jonathan Cauthorn • 3 years ago
"If all you have is a hammer, the world looks like nails." Point taken, most ID Admins have a hammer called PowerShell, and wield it accordingly. In that case, you might want to consider putting your code on one of the many sites that host open-source code and allow and encourage other PowerShell programmers to enjoy and enhance it. It wouldn't hurt to teach them source control too! CodePlex, run by Microsoft would be a good start, or check out this for more options: https://en.wikipedia.org/wi... Assembla, GitHub, SourceForge are good options too. 1
• Reply • Share ›
Adam The Automator • 3 years ago
I realize other options are out there. I'm not ignorant to that fact. I'm not a developer nor do I pretend to me. Open source products are developed by developers. "Not customizable" means different things to different people. Your typical IT pro is probably not going to be contribute to an open source project because he doesn't know C#, .NET, C++, etc. However, he does know Powershell. Creating an IPAM solution in Powershell allows us non-developers to customize tools more easily rather than learning another language. IMO, if you know a language well, enjoy writing in Powershell then why not build your own solution? You'll learn a lot in the process and have a nice, working tool when you're done. 1
• Reply • Share ›
Jonathan Cauthorn • 3 years ago
Dude, seriously, I get it that you want to talk PowerShell in this column, but: "If enough work is put into it, this module could evolve into a feature-rich solution!" doesn't really jive with the statement: "I have seen several open source IPAM tools that are free, but they aren't easily customizable and they're overkill for what I need." You need to do more homework. You can use SolarWinds or IPAM Express for limited environments. There is also good open source - which you CAN customize (hence: Open Source): http://phpipam.net/ http://iptrack.sourceforge.... or check out the list at: https://en.wikipedia.org/wi... This just seems like a solution looking for a problem that has already been solved. :)
• Reply • Share ›
ALSO ON MICROSOFT CERTIFIED PROFESSIONAL MAGAZINE
Creating a Balloon Tip Notification Using PowerShell -- Microsoft Certified … 7 comments • 7 months ago
Encrypting Data with PowerShell Cmdlets -- Microsoft Certified … 1 comment • 6 months ago
NightLife6 — A very good review (with Examples) of the of the basics of
Mario Veras — Is there a way to have the toast notification show up
PKI and how to implement via use of PowerShell …
without a tray icon? I find that if run multiple times, the …
Understanding Parallel Runspaces in PowerShell -- Microsoft Certified …
Exploring Dot-Sourcing in PowerShell -- Microsoft Certified Professional …
2 comments • 8 months ago
3 comments • a year ago
Paul M — Your use of synchronous and asynchronous is flipped around
dizzi90 — I usually use:.
in the first paragraph.Thanks for sharing about …
"$PSScriptRoot\..\Function\Functionname.ps1"And put each function to be exported as a …
Subscribe
Add Disqus to your siteAdd DisqusAdd
Privacy
Most Popular Articles Find Data in Excel Using PowerShell CPU Fixes for Spectre Variant 2 Roll Out from AMD Microsoft To Update Azure Active Directory's Login Design Working with PowerShell History Organizing Your PowerShell Code Using Regions
Free Whitepapers Managing More Than One Worksite? Don’t Sweat I.T Security Is One Thing. Confidence Is Another Best Practices for Protecting Against Phishing, Ransomware, and Email 5 Ways IT Resilience Beats Disaster Recovery More TechLibrary
SharePoint Watch Sign up for our newsletter. Email Address:
[email protected]
I agree to this site's Privacy Policy.
SUBMIT
Free Webcasts How to Survive Windows 10 Updates Top Tips for IT Pros in Education to Know Security Sensemaking: The Magical Number Seven, Plus or Minus Two A Hacker Explains - How Your IT Environment Can Be Compromised More Webcasts
Sponsored Links Considering moving your fax operations to the cloud? Download the white paper: The Cloud Fax Advantage!
CONTACT US
ADVERTISE
Are you scheduling a data migration?
Are you scheduling a data migration?
LinkFixer Advanced removes a common cause of inaccurate and problematic migrations -- broken links. Get a FREE LinkFixer Advanced trial now!
LinkFixer Advanced removes a common cause of inaccurate and problematic migrations -- broken links. Get a FREE LinkFixer Advanced trial now!
ARCHIVES
EVENTS
WINDOWS INSIDER
FREE NEWSLETTERS
REPRINTS
Application Development Trends
AWSInsider.net
Enterprise Systems
MCPmag.com
Redmond
Redmond Channel Partner
Redmond Events
Redmond Media Group
Redmond Report
Virtualization Review
Visual Studio Magazine
© 1998-2018 1105 Media Inc. See our Privacy Policy and Terms of Use.
Problems? Questions? Feedback? E-mail us.
LIST RENTAL