Get subnet calculations using PowerShell. Here is a great PowerShell module I came across that lets you do all you subnet calculations easily.
If you have PowerShell 5 or greater simply run the command:
Install-Module Subnet -Scope CurrentUser
*You may need to accept the install from the repository.
The Get details about a subnet use the Get-Subnet command:
Get-Subnet 192.168.1.1/24
If no Subnet mask size was not specified the cmdlet with use the default subnet size for a Class C network of /24.
The output will look as follows:
IPAddress : 192.168.1.1
MaskBits : 24
NetworkAddress : 192.168.1.0
BroadcastAddress : 192.168.1.255
SubnetMask : 255.255.255.0
NetworkClass : C
Range : 192.168.1.0 ~ 192.168.1.255
HostAddresses : {192.168.1.1, 192.168.1.2, 192.168.1.3, 192.168.1.4…}
HostAddressCount : 254
To get info about a specified subnet using the MaskBits parameter use:
Get-Subnet -IP 192.168.1.1 -MaskBits 20
The output will look as follows:
IPAddress : 192.168.1.1
MaskBits : 20
NetworkAddress : 192.168.0.0
BroadcastAddress : 192.168.15.255
SubnetMask : 255.255.240.0
NetworkClass : C
Range : 192.168.0.0 ~ 192.168.15.255
HostAddresses : {192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4…}
HostAddressCount : 4094
If the subnet size specified is larger than a /16, it will not return the host addresses by default. You can force the cmdlet to return all host addresses with -Force.