GETMAC - CMD


Overview

The GETMAC command is a utility in Windows operating systems used to display the Media Access Control (MAC) addresses of network devices on a local computer. This can be useful for network configuration and troubleshooting, as well as security auditing. The command identifies MAC addresses for all network adapters, whether physical or virtual.

Syntax

To use the GETMAC command, its basic syntax is:

GETMAC [/S system [/U username [/P [password]]]] [/FO format] [/NH] [/V]
  • /S system – Specifies the remote system to connect to.
  • /U username – Specifies the username with which to logon.
  • /P [password] – Specifies the password for the given username. If omitted, prompts for input.
  • /FO format – Specifies the format in which to display the output. Valid values are “TABLE”, “LIST”, “CSV”.
  • /NH – Suppresses column headers in the output. Useful for scripting.
  • /V – Enables verbose mode, providing more detailed information.

Options/Flags

  • /S system: Useful for querying MAC addresses from a remote machine. Requires administrative privileges on the remote system.
  • /U username / /P [password]: Used when accessing a remote machine that requires authentication.
  • /FO format: Changes the output format to one of the specified. “TABLE” is the default format and is typically the easiest to read. “CSV” is particularly useful for importing the results into a spreadsheet.
  • /NH: Particularly useful when parsing the output with scripts, removing headers simplifies the data processing.
  • /V: Verbose mode provides detailed output, such as adapter type and status. This can be helpful for deeper network analysis.

Examples

  1. Simple Usage to Display MAC Addresses:

    GETMAC
    
  2. Display MAC Addresses in CSV Format:

    GETMAC /FO CSV
    
  3. Remote MAC Address Fetching:

    GETMAC /S workstation01 /U user /P password
    
  4. Verbose Output Without Headers:

    GETMAC /V /NH
    

Common Issues

  • Access Denied: When querying a remote computer, ensure you have the appropriate permissions or you might receive an “Access Denied” error.
  • Output Format Confusion: Users new to GETMAC might find the output confusing without headers. It’s helpful to test the command without the /NH flag first to understand the data structure.

Integration

GETMAC can be combined with other commands for more comprehensive network scripts. For instance, using FOR /F loops in CMD scripts can parse the MAC addresses and use them in network configuration scripts.

Example of listing all MAC addresses and writing them into a text file:

GETMAC /FO CSV /NH > mac_list.txt
  • IPCONFIG: Displays all current TCP/IP network configuration values.
  • PING: Sends ICMP ECHO_REQUEST packets to network hosts.
  • ARP: Displays and modifies the IP-to-Physical address translation tables used by address resolution protocol (ARP).

For further reading about network commands and configurations, Microsoft’s official documentation and resources on network administration are recommended Windows Command Line Documentation.