how to get MAC address of remote computer
Solution 1:
MAC addresses are Ethernet things, not Internet things. A computer need not even have a MAC address. The only way to get the MAC address is to get some computer on the same LAN as that computer to tell it to you. And you'd have no way to know it was giving you the correct information.
If the two of you are in the same Ethernet LAN, you can just ping
the computer and then look in your ARP table. Otherwise, you would have to ask a computer in the same Etherent/Wifi LAN.
Solution 2:
You can get it from WMI, and any language that can read WMI will be able to access it. VBScript, JScript, Perl, Python, and Powershell can all be used to get to it.
Since you asked specifically Powershell, here's an example from http://www.neolisk.com/techblog/powershell-getmacaddressofanyremoteip:
param ( $Computer , $Credential )
#to make it work without parameters
if($Computer -eq $null) { $Computer = $env:COMPUTERNAME }
#program logic
$hostIp = [System.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString
if($Credential) {
$Credential = Get-Credential $Credential
$wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer
} else {
$wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer
}
return ($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress
Solution 3:
nmap will return the MAC address as well as just about anything else you'd like to know.
If you have admin access to the machine, powershell & wmi are both very useful in getting remote diagnostics. They both have extensive documentation at technet.microsoft.com
edit: this assumes a windows machine, which from the looks of it, this might not be.
Solution 4:
yep. The easiest way should be just doing a ping and then check the ARP table
If you're more into actually getting stuff inventoried and reported I would suggest havoing a look at the free software from Spiceworks ( http://www.spiceworks.com ) to set upp constant monitoring and always havce your information easily available about your entire enivorenment.
I've used it for years and it works great on LAN.
It does have some issues with sending inventories ocf sofwtare to remote sites though, haven't really figured out why yet but apart from that, I highly recommend it .
Solution 5:
If you know name of computer easies way will be:
$strComputer ="ComuterName"
$colItems = Get-WmiObject -Class "Win32_NetworkAdapterConfiguration" -ComputerName $strComputer -Filter "IpEnabled = TRUE"
ForEach ($objItem in $colItems)
{
write-host "IP Address: " $objItem.IpAddress[0] "Mac: " $objItem.MacAddress
}
More advanced script which can take any machine by IP or hostname:
$device = "192.168.106.123"
if ( $device | ? { $_ -match "[0-9].[0-9].[0-9].[0-9]" } )
{
echo "Searching MAC by IP"
$ip = $device
}
else
{
echo "Searching MAC by host"
$ip = [System.Net.Dns]::GetHostByName($device).AddressList[0].IpAddressToString
}
$ping = ( new-object System.Net.NetworkInformation.Ping ).Send($ip);
if($ping){
$mac = arp -a $ip;
( $mac | ? { $_ -match $ip } ) -match "([0-9A-F]{2}([:-][0-9A-F]{2}){5})" | out-null;
if ( $matches )
{
$matches[0];
} else
{
echo "MAC Not Found"
}
}