< Back
Get-SubnetSize
Post
NAME Get-SubnetSize
SYNOPSIS
Returns the possible number of hosts that a subnet can contain.
SYNTAX
Get-SubnetSize [-CIDR] <String> [[-IncludeSubnetIDAndBroadcastAddress]] [<CommonParameters>]
Get-SubnetSize [-SubnetMask] <String> [[-IncludeSubnetIDAndBroadcastAddress]] [<CommonParameters>]
DESCRIPTION
This function returns the possible number of hosts that the subnet can contain, by default it excludes the Subnet
ID and Broadcast addresses.
Shout out to
http://blog.markhatton.co.uk/2011/03/15 ... hostnames/
and https://social.msdn.microsoft.com/Forum ... gular-expr
ession-for-subnet-mask-2552552550-for-example?forum=regexp
for regex validation patterns!
Found the calculation logic online too, when I refind the links will include in shoutout.
PARAMETERS
-CIDR <String>
Subnet in CIDR format
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-SubnetMask <String>
Subnet Mask
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-IncludeSubnetIDAndBroadcastAddress [<SwitchParameter>]
Include subnet id and broadcast address
Required? false
Position? 2
Default value False
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
Can accept strings of CIDR format from pipeline.
OUTPUTS
[Long] size of the subnet.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-SubnetSize -CIDR 192.168.1.0/24
Returns the size of the subnet CIDR 192.168.1.0/24
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-SubnetSize -SubnetMask 255.255.0.0
Returns the size of the subnet with mask 255.255.0.0
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-SubnetSize -SubnetMask 255.0.0.0 -IncludeSubnetIDAndBroadcastAddress
Returns the size of the subnet with mask 255.0.0.0, including the id and broadcase
RELATED LINKS
https://github.com/poshsecurity/Posh-SubnetTools
Github for project
https://poshsecurity.com
Posh Security Website
SYNOPSIS
Returns the possible number of hosts that a subnet can contain.
SYNTAX
Get-SubnetSize [-CIDR] <String> [[-IncludeSubnetIDAndBroadcastAddress]] [<CommonParameters>]
Get-SubnetSize [-SubnetMask] <String> [[-IncludeSubnetIDAndBroadcastAddress]] [<CommonParameters>]
DESCRIPTION
This function returns the possible number of hosts that the subnet can contain, by default it excludes the Subnet
ID and Broadcast addresses.
Shout out to
http://blog.markhatton.co.uk/2011/03/15 ... hostnames/
and https://social.msdn.microsoft.com/Forum ... gular-expr
ession-for-subnet-mask-2552552550-for-example?forum=regexp
for regex validation patterns!
Found the calculation logic online too, when I refind the links will include in shoutout.
PARAMETERS
-CIDR <String>
Subnet in CIDR format
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-SubnetMask <String>
Subnet Mask
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-IncludeSubnetIDAndBroadcastAddress [<SwitchParameter>]
Include subnet id and broadcast address
Required? false
Position? 2
Default value False
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
Can accept strings of CIDR format from pipeline.
OUTPUTS
[Long] size of the subnet.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-SubnetSize -CIDR 192.168.1.0/24
Returns the size of the subnet CIDR 192.168.1.0/24
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-SubnetSize -SubnetMask 255.255.0.0
Returns the size of the subnet with mask 255.255.0.0
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-SubnetSize -SubnetMask 255.0.0.0 -IncludeSubnetIDAndBroadcastAddress
Returns the size of the subnet with mask 255.0.0.0, including the id and broadcase
RELATED LINKS
https://github.com/poshsecurity/Posh-SubnetTools
Github for project
https://poshsecurity.com
Posh Security Website