Forum Discussion
Edmund_Fearon
Mar 20, 2024Copper Contributor
Powershell script to pull MAC addresses from Intune
I am after the Powershell Commands to retrieve the ethernet MACs of enrolled devices in Intune. The aim is to create a script that pulls the MAC addresses for all enrolled devices at once. An...
dhako94
Mar 24, 2024Copper Contributor
Hi,
unfortunately the standard output of Get-MgDeviceManagementManagedDevice does not contain the EthernetMacAddress, only the WiFiMacAddress. so you have to call the device again separately here is a script
$allIntuneDevices = Get-MgDeviceManagementManagedDevice -All
$outputFilePath = "C:\temp\IntuneDevices.txt"
foreach ($intuneDevice in $allIntuneDevices) {
$singelDevice = Get-MgDeviceManagementManagedDevice -ManagedDeviceId $intuneDevice.ID | Select DeviceName, EthernetMacAddress, OperatingSystem
$singelDevice | Export-Csv -Path IntuneDevices.csv -Delimiter ";" -Encoding utf8 -IncludeTypeInformation -Append
#or in your format
$output = "Device: $($singelDevice.DeviceName)
Operating System: $($singelDevice.OperatingSystem)
Ethernet MAC: $($singelDevice.WiFiMacAddress)"
Write-Output $output
$output | Out-File -FilePath $outputFilePath -Append
}
JamesAtBryan
Jun 06, 2024Copper Contributor
Hi Dominik,
Thank you for the script it was very helpful in getting the mac addresses from Intune, but I just wanted to let you know there is a typo on line 10 it should be Ethernet MAC: $($singelDevice.EthernetMacAddress)"
but again thank you very much for the script.
-James
Thank you for the script it was very helpful in getting the mac addresses from Intune, but I just wanted to let you know there is a typo on line 10 it should be Ethernet MAC: $($singelDevice.EthernetMacAddress)"
but again thank you very much for the script.
-James