PoshCode Archive  Artifact [83e707bcd1]

Artifact 83e707bcd1743492e428037a2ca877eb7fc8b685c55c5b4a807b49ac81b42edf:

  • File validate-an-IP-address.ps1 — part of check-in [5fcf0ad63f] at 2018-06-10 12:56:35 on branch trunk — validates given IP address and returns True/False (user: ucthakur size: 481)

# encoding: ascii
# api: powershell
# title: validate an IP address
# description: validates given IP address and returns True/False
# version: 0.1
# author: ucthakur
# license: CC0
# x-poshcode-id: 1166
# x-derived-from-id: 1170
# x-archived: 2009-06-27T00:34:45
#
#
# validate given IP address in $ip1 variable
$ip1 = "192.168.22.455"
($ip1.split(".") | where-object { $_ -ge 1 -and $_ -le 255 } | Where-Object { $_ -match "\d{1,3}"} | Measure-Object).count -eq 4