Skip to content

Assert‑IPv4Address

viscalyxbot edited this page Sep 15, 2025 · 1 revision

SYNOPSIS

Asserts that a string is a valid IPv4 address.

SYNTAX

Assert-IPv4Address [-IPAddress] <String> [<CommonParameters>]

DESCRIPTION

Validates that the input string represents a valid IPv4 address by checking both format and value ranges (0-255 for each octet). This command also validates that octets do not have leading zeros (except for '0' itself) which is important for proper IPv4 address validation. Throws an exception if the input is not a valid IPv4 address.

EXAMPLES

EXAMPLE 1

Assert-IPv4Address -IPAddress '192.168.1.1'

This example validates a standard IPv4 address. No output is returned if the validation succeeds.

EXAMPLE 2

Assert-IPv4Address -IPAddress '999.999.999.999'

This example demonstrates validation failure for an invalid IPv4 address with octets exceeding 255.

EXAMPLE 3

Assert-IPv4Address -IPAddress '192.168.01.1'

This example demonstrates validation failure for an IPv4 address with leading zeros in an octet.

PARAMETERS

-IPAddress

Specifies the string to validate as an IPv4 address. The string should be in the format of four decimal numbers separated by periods.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
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

None

OUTPUTS

None. This command does not return a value but throws an exception if

validation fails.

NOTES

RELATED LINKS

Clone this wiki locally