function Ping-Host([string]$hostName) { $pinger = new-object system.Net.NetworkInformation.Ping; return $pinger.Send($hostName); } function Resolve-HostByAddress([string]$ipAddress) { return [System.Net.Dns]::GetHostByAddress($ipAddress); } function Resolve-HostByName([string]$hostName) { return [System.Net.Dns]::GetHostByName($hostName); } function New-MachineObject($hostName = "", $ipAddress = "", $macAddress = "", $alive = "") { $machine = New-Object System.Object; Add-Member -InputObject $machine -MemberType NoteProperty -name "HostName" -Value $hostName; Add-Member -InputObject $machine -MemberType NoteProperty -name "IpAddress" -Value $ipAddress; Add-Member -InputObject $machine -MemberType NoteProperty -name "MacAddress" -Value $macAddress; Add-Member -InputObject $machine -MemberType NoteProperty -name "Alive" -Value $alive; return $machine; } function Get-MacAddressForHost($hostName, $ipAddress) { $networkAdapters = get-wmiobject Win32_NetworkAdapterConfiguration -computername $hostName -Filter "IPenabled = 'True'"; foreach ($adapter in $networkAdapters) { if ($adapter.IPAddress -eq $ipAddress) { return $adapter.MACAddress; } } } function Get-AliveStatus($hostName) { $response = Ping-Host $hostName; if ($response.Status -eq [System.Net.NetworkInformation.IPStatus]::Success) { return $true; } else { return $false; } }