![]() ![]() $NoOfZerosToAdd = $HostIDInBinary.Length – $NextHostIDInBinary. $NextHostIDInBinary = ::ToString($NextHostIDInDecimal,2) $NextHostIDInDecimal = (::ToInt32($HostIDInBinary,2) + $i) $IPs = ID is first network ID converted to decimal plus $i then converted to binary #Work out all the host IDs in that subnet by cycling through $i from 1 up to max $HostIDInBinary (i.e. $HostIDInBinary = $IPInBinary.Substring($SubnetBits,$HostBits) $NetworkIDInBinary = $IPInBinary.Substring(0,$SubnetBits) #Get network ID by subtracting subnet mask $IPInBinary = $IPInBinary + $OctetInBinary $OctetInBinary = (“0” * (8 – ($OctetInBinary).Length) + $OctetInBinary) Back to top Why Use a Subnetting Calculator To put it simply, to use a subnetting calculator you need only input a range of CIDR notations or IP addresses. #get length of binary string add leading zeros to make octet Subnet calculatorssometimes known as subnet range calculators or subnet mask calculatorswill retrieve subnetwork info from both the IP address and the subnet mask. #Split IP into different octects and for each one, figure out the binary with leading zeros and add to the total You can then pipe out the IPs so you can run a command on each: Here is a PowerShell function that will output an array of all the IPs on a particular subnet. It’s quite simple to generate the list of IPs for a /24 subnet but is a little trickier for the other subnets, e.g. I’m often faced with situations when I need to scan entire subnets to find devices and either perform an inventory or run a remote PowerShell command on all the devices on a subnet. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |