Private/VirtualNetwork/NextIp.ps1
function NextIp { [CmdletBinding()] param( # CIDR notation network address, or using subnet mask. Examples: '192.168.0.1/24', '10.20.30.40/255.255.0.0'. [Parameter(Mandatory = $True)][string] $Ip ) $t = $Ip.Split(".") if ($t[3] -eq 255 -and $t[2] -eq 255) { if (([int]$t[1]) -eq 255 ) { $nextIp = $null } $nextIp = $t[0] + "." + [string]([int]$t[1] + 1) + ".0.0" } elseif ([int]$t[2] -ne 255 -and [int]$t[3] -eq 255 ) { $nextip = $t[0] + "." + $t[1] + "." + [string]([int]$t[2] + 1) + ".0" } elseif ([int]$t[3] -ne 255) { $nextIp = $t[0] + "." + $t[1] + "." + $t[2] + "." + [string]([int]$t[3] + 1) } return $nextIp } |