Test-IsValidIP

Test if an IP address has a valid format, IPv4 or IPv6

 

Function Test-IsValidIP {
[CmdletBinding()]
Param (
[parameter(ValueFromPipeLine=$True,ValueFromPipeLineByPropertyName=$True)]
[Alias("IP")]
[string]$IPAddress
)

Process {
Try {
[ipaddress]$IPAddress | Out-Null
Write-Output $True
} Catch {
Write-Output $False
}
}
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top