Skip to content

Test‑IPv4Address

viscalyxbot edited this page Sep 15, 2025 · 1 revision

SYNOPSIS

Tests if a string is a valid IPv4 address.

SYNTAX

Test-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. Returns true if the input is a valid IPv4 address, false otherwise.

EXAMPLES

EXAMPLE 1

Test-IPv4Address -IPAddress '192.168.1.1'

This example tests a standard IPv4 address and returns True.

EXAMPLE 2

'192.168.1.1', '10.0.0.1' | Test-IPv4Address

This example demonstrates pipeline input with multiple IP addresses.

EXAMPLE 3

Test-IPv4Address -IPAddress '999.999.999.999'

This example tests an invalid IPv4 address with octets exceeding 255 and returns False.

EXAMPLE 4

Test-IPv4Address -IPAddress '192.168.01.1'

This example tests an IPv4 address with leading zeros in an octet and returns False.

PARAMETERS

-IPAddress

Specifies the string to test 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: True (ByValue)
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

System.String

Accepts strings from the pipeline for testing as IPv4 addresses.

OUTPUTS

[System.Boolean]

Returns true if the string is a valid IPv4 address, false otherwise.

NOTES

This command performs strict validation including checking for leading zeros which are not allowed in standard IPv4 address notation.

RELATED LINKS

Clone this wiki locally