Skip to content

Assert IPAddress

dscbot edited this page Feb 13, 2024 · 2 revisions

Assert-IPAddress

SYNOPSIS

Asserts if the IP Address is valid and optionally validates the IP Address against an Address Family.

SYNTAX

Assert-IPAddress [[-AddressFamily] <String>] [-Address] <String> 
 [<CommonParameters>]

DESCRIPTION

Checks the IP address so that it is valid and do not conflict with address family. If any problems are detected an exception will be thrown.

EXAMPLES

EXAMPLE 1

Assert-IPAddress -Address '127.0.0.1'

This will assert that the supplied address is a valid IPv4 address. If it is not an exception will be thrown.

EXAMPLE 2

Assert-IPAddress -Address 'fe80:ab04:30F5:002b::1'

This will assert that the supplied address is a valid IPv6 address. If it is not an exception will be thrown.

EXAMPLE 3

Assert-IPAddress -Address 'fe80:ab04:30F5:002b::1' -AddressFamily 'IPv6'

This will assert that address is valid and that it matches the supplied address family. If the supplied address family does not match the address an exception will be thrown.

PARAMETERS

-Address

Specifies an IPv4 or IPv6 address.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AddressFamily

IP address family that the supplied Address should be in. Valid values are 'IPv4' or 'IPv6'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

RELATED LINKS

Clone this wiki locally