Random SysAdmin Thoughts...

Adventures in DevOps and other random technical musings

Get MAC Addresses through PowerShell

$Servers = Import-Csv c:\Temp\servers.csv

foreach ($Server in $Servers) {
$NetAdapter = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $Server.Name -Filter “IpEnabled = TRUE”
foreach ($Adapter in $NetAdapter) {
$Name = $Server.Name
$MAC = $Adapter.MacAddress
Write-Host “$Name - $MAC”

We needed to get the MAC addresses for the network team and I didn’t have a script for it in my library. We already had the list of servers we need, so I used that to query WMI and return the MAC on the adapters that would be connected to the network.