# 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