GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing ss64.com — GetMac command - Windows CMD GetMac.exeDisplay the Media Access Control (MAC) address and list of network protocols associated with each address for all network cards in each computer, either locally or across a network. Syntax
GETMAC [/s Computer [/u Domain\User [/p Password]]]
[/fo {TABLE|LIST|CSV}] [/nh] [/v]
Key
/s Computer The name or IP address of a remote computer
(do not use backslashes). Default = local computer.
/u Domain\User Run the command with the account permissions of the
user specified. Default = the currently logged on user.
/p Password The password of the user account that is specified in the /u parameter.
/fo { TABLE | LIST | CSV }
Format the output. Default = TABLE.
/nh Omit the header row from the displayed driver information.
Valid when the /fo parameter is set to TABLE or CSV.
/v Display verbose information.
/? Display Help.
ExamplesShow all MAC addresses in Table output:
Show MAC addresses on server64:
Show MAC addresses on server64 and authenticate as a different user:
Export a verbose listing of MAC addresses to a CSV file:
PowerShell script to get the Mac address of the current machine:
PowerShell script to collect Mac addresses for multiple machines by calling GetMac: # Create empty hash table
$macHash=@{}
# Load a list of machine names
$servers=get-content c:\batch\servers.txt
foreach ($server in $servers) {
if (Test-Connection $server -quiet) { # if it responds to a Ping
# Call the GetMac utility
$getmac=getmac /nh /fo csv /s $server
$macAddresses=$getmac -split ","
$interface = 1
$macAddresses | foreach {
if ($_ -ne ""){
# check for a '-' to see if we have a mac address
if ($_.substring(3,1) -eq "-") {
# Remove quotes
$addr = $_.replace("""","")
$adapter = $interface/2
Echo "$server Adapter:$adapter $addr"
# Save in the hash variable
$macHash.add("$server Adapter:$adapter",$addr)
}
}
$interface += 1
}
}
}
# Export the hash table to a spreadsheet
$macHash.GetEnumerator() | select name, value | Sort-Object Name | Export-CSV -Path "c:\batch\macaddresses.csv" -NoTypeInformation
“I am the literary equivalent of a Big Mac and Fries” ~ Stephen King (Writer, best known for horror novels.) Related commandsDevCon - Device Manager Command Line Utility. Copyright © 1999-2026 SS64.com
Some rights reserved |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |