< Back
Test-SubnetMember
Post
NAME Test-SubnetMember
SYNOPSIS
Tests an IP address to determine if it falls within IP address range.
SYNTAX
Test-SubnetMember [-SubjectIPAddress] <String> [-ObjectIPAddress] <String> [-SubjectSubnetMask <String>]
[-ObjectSubnetMask <String>] [<CommonParameters>]
DESCRIPTION
Test-SubnetMember attempts to determine whether or not an address or range falls within another range. The network
and broadcast address are calculated the converted to decimal then compared to the decimal form of the submitted
address.
PARAMETERS
-SubjectIPAddress <String>
A representation of the subject, the network to be tested. Either a literal IP address, a network range
expressed as CIDR notation, or an IP address and subnet mask in a string.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ObjectIPAddress <String>
A representation of the object, the network to test against. Either a literal IP address, a network range
expressed as CIDR notation, or an IP address and subnet mask in a string.
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SubjectSubnetMask <String>
A subnet mask as an IP address.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ObjectSubnetMask <String>
A subnet mask as an IP address.
Required? false
Position? named
Default value
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
OUTPUTS
System.Boolean
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 10.0.0.0/24 -ObjectIPAddress 10.0.0.0/16
Returns true as the subject network can be contained within the object network.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 192.168.0.0/16 -ObjectIPAddress 192.168.0.0/24
Returns false as the subject network is larger the object network.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 10.2.3.4/32 -ObjectIPAddress 10.0.0.0/8
Returns true as the subject IP address is within the object network.
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 255.255.255.255 -ObjectIPAddress 0/0
Returns true as the subject IP address is the last in the object network range.
RELATED LINKS
SYNOPSIS
Tests an IP address to determine if it falls within IP address range.
SYNTAX
Test-SubnetMember [-SubjectIPAddress] <String> [-ObjectIPAddress] <String> [-SubjectSubnetMask <String>]
[-ObjectSubnetMask <String>] [<CommonParameters>]
DESCRIPTION
Test-SubnetMember attempts to determine whether or not an address or range falls within another range. The network
and broadcast address are calculated the converted to decimal then compared to the decimal form of the submitted
address.
PARAMETERS
-SubjectIPAddress <String>
A representation of the subject, the network to be tested. Either a literal IP address, a network range
expressed as CIDR notation, or an IP address and subnet mask in a string.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ObjectIPAddress <String>
A representation of the object, the network to test against. Either a literal IP address, a network range
expressed as CIDR notation, or an IP address and subnet mask in a string.
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SubjectSubnetMask <String>
A subnet mask as an IP address.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ObjectSubnetMask <String>
A subnet mask as an IP address.
Required? false
Position? named
Default value
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
OUTPUTS
System.Boolean
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 10.0.0.0/24 -ObjectIPAddress 10.0.0.0/16
Returns true as the subject network can be contained within the object network.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 192.168.0.0/16 -ObjectIPAddress 192.168.0.0/24
Returns false as the subject network is larger the object network.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 10.2.3.4/32 -ObjectIPAddress 10.0.0.0/8
Returns true as the subject IP address is within the object network.
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Test-SubnetMember -SubjectIPAddress 255.255.255.255 -ObjectIPAddress 0/0
Returns true as the subject IP address is the last in the object network range.
RELATED LINKS