Often I find myself needing to check input for a valid IP Address. Regex is a common way to solve this, but here is a MUCH simpler way. The IPAddress .Net method is easier and much more straight-forward.
I used this recently to extract IP addresses from a logfile.
1 2 3 4 | IF ( [BOOL]($LineArray[3] -as [IPADDRESS]) ) { ## OPEN IF - Check IF $LineArray[3] is IP $LineClientIP = $LineArray[3] } ## OPEN IF - Check IF $LineArray[3] is IP |