I am trying to work out how to parse an array for IP addresses. I have already worked out how to resolve the IP to DNS Hostname so far I have this:
Function Get-IP-Hostname
{
Param([string[]]$array)
$array.length
foreach ($element in $array)
{
$hname = [System.Net.Dns]::GetHostByAddress($element).HostName
$regex = "[regex] (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
@{$element = $hname}
}
}
When I execute
Get-IP-Hostname 192.168.150.xx 192.168.151.xx
with a bunch of IPs I have to use a comma to split, separate the string - my RegEx does not seem to split without a comma.
I am trying to get this output:
> Name Value
>
> ---- -----
> 192.168.150.xx ank70dom07.akgroup.com
> 192.168.151.xx ank70dom07.akgroup.com
I am pretty new to PowerShell and would appreciate any help.
Thanks!