# Script to get MAC address of Windows devices

Knowing your device’s MAC address is very important as it helps in identifying a specific device from a fleet of devices. It can be used to filter out certain devices from connecting to a specific network or be used to monitor network traffic on a specific device. Since every device has a unique MAC address, it is the best parameter to identify a device and perform actions on it. Hexnode offers a feature where you can fetch the MAC address of a Windows device remotely by executing [custom scripts](https://www.hexnode.com/mobile-device-management/help/executing-custom-scripts-for-windows/).

 Disclaimer:The sample scripts provided below are adapted from third-party open-source sites.

 

Batch Script
------------

### Using the ‘ipconfig’ command 

batch script to find mac address on windows using ipconfig command

ipconfig /all 

   1

  ipconfig /all 

   

 

  

This script displays different parameters of your Windows device’s IP configuration. The Physical Address listed here is the MAC address of your Windows device.

### Using the ‘getmac’ command

batch script to get Mac address of Windows using getmac command

getmac

   1

  getmac

   

 

  

This script displays the MAC addresses associated with all the active network adapters on your Windows device.

PowerShell Script
-----------------

The following PowerShell script displays the network MAC address of a Windows device.

PowerShell scrip to fetch MAC address of Windows device

Get-NetAdapter | Select-Object Name, MacAddress 

   1

  Get-NetAdapter | Select-Object Name, MacAddress 

   

 

  

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.