Mac address capture
-
Tuesday, December 04, 2012 9:14 AM
Hi,
I am trying to capture MAC address and unable to capture just the mac address, it gives the following :
@{MacAddress=00:50:56:83:03:9X}
Have used these:
$nics_server = Get-WmiObject win32_networkadapterconfiguration | where {$_.ipEnabled -eq $True} | select MacAddress
Write-Host $nics_serverand
$nics_server = Get-WmiObject win32_networkadapter | where {$_.NetEnabled -eq $True} | select MacAddress
Write-Host $nics_serverhow do i just capture "00:50:56:83:03:9X"?
All Replies
-
Tuesday, December 04, 2012 9:22 AM
You need to use the -expandproperty switch...
$nics_server = Get-WmiObject win32_networkadapter | where {$_.NetEnabled -eq $True} | select -ExpandProperty MacAddress
...because, as you can see, the command returns an array. @{....}
-ExpandProperty 'unrolls'/'unwraps' (depending on what you read) the array into its individual elements... of which, in your case, there can be only one... um.. there is only one.
Admiral Ackbar says...
- Edited by RiffyRiotMicrosoft Community Contributor Tuesday, December 04, 2012 9:25 AM
- Marked As Answer by PoSHV Tuesday, December 04, 2012 9:25 AM
-
Tuesday, December 04, 2012 9:24 AMThank you very so much :)

