Getting IP Network Information with Powershell

Those of us that have tried to manipulate IPv4 information in Powershell know that out of the box, it isn’t the easiest thing to do. Problem is that in calculating IPv4 information such as broadcast address, network address, and host range properly, you have to manipulate it in it’s 32-bit form, and not its integer format.

After having to do this the hard way a few times, I decided to write a script that I could use for a wide array of scenarios to get this information, and now I’m passing the time savings onto you!

You can use either CIDR notation (e.g. 192.168.1.1/24) or IP address and subnet mask to get an object that contains info on the network.

If I want the output object to also contain an array of IPs within that network, I can use the -IncludeIPRange switch parameter:

The Script

Hope this helps, and happy scripting!

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *