
내 코드는 다음과 같습니다. Power Shell에서 시도했지만 IP, Mac 주소 및 호스트 이름 목록의 절반만 볼 수 있으며 동료 IP 주소는 볼 수 있지만 관리자의 IP 주소는 볼 수 없습니다.
$result = New-Object -TypeName System.Collections.ArrayList
(arp -a) -Match '\s\s\d' |
ForEach-Object {
$parts = $_.trim() -Split '\s+'
Try {
$HostName = ([Net.Dns]::GetHostByAddress($parts[0])).HostName
}
Catch{
$Hostname = "No Hostname found"
}
$info = [pscustomobject]@{
IPAddress = $parts[0]
MACAddress = $parts[1]
Type = $parts[2]
HostName = $HostName
}
$null = $result.Add($info)
}
$result