Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Check-IP
- {
- PARAM
- (
- $ip
- )
- try
- {
- [System.Net.IPAddress]$ip1 = $ip
- if ($ip1.AddressFamily -match 'v6')
- {
- $type = 'IPv6'
- }
- else
- {
- $type = 'IPv4'
- if (($ip.Split('.')).count -ne 4)
- {
- Write-Host -ForegroundColor Red "$ip" -NoNewline
- Write-Host -ForegroundColor White " - " -NoNewline
- Write-Host -ForegroundColor Gray "is not a valid $type address"
- break;
- }
- }
- Write-Host -ForegroundColor Green "$ip" -NoNewline
- Write-Host -ForegroundColor White " - " -NoNewline
- Write-Host -ForegroundColor Gray "is a Valid $type address"
- }
- catch
- {
- if ($type -eq $null)
- {$type = 'IPv6'}
- Write-Host -ForegroundColor Red "$ip" -NoNewline
- Write-Host -ForegroundColor White " - " -NoNewline
- Write-Host -ForegroundColor Gray "is not a valid $type address"
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement