GetMac.exe – Windows CMD Command
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Display 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
Examples Show all MAC addresses in Table output: getmac /fo table /nh /v Show MAC addresses on serverF4T getmac /s serverF4T Show MAC addresses on serverF4T and authenticate as a different user: getmac /s serverF4T /u F4TDom\user583 Export a verbose listing of MAC addresses to a CSV file getmac /v /fo csv > T:\macaddresses.csv PowerShell script to get the Mac address of the current machine: $Mac = getmac /fo csv | ConvertFrom-Csv 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 |