how get it alone mac adress from Object to String or Array of String

Salvo Gallitano 21 Reputation points
2022-04-22T13:43:46.01+00:00

hello,
somebody among you, Do you know how to get only mac adress in string type?

I do follows commands:

$A = get-netadapter -name "ethernet" | format-list -Property "macaddress"
PS U:\users\SalvatoreGallitano> $a

MacAddress : 1C-1B-0D-9F-00-00

PS U:\users\SalvatoreGallitano> $a.GetType()

IsPublic IsSerial Name BaseType


True True Object[] System.Array

I wold like only mac code in string type but i do not get it.
it say that it is a array with 5 element but i can't access to it.
i tried this:
$a[0] or other numbers but anything.

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Justin Iven Müller 76 Reputation points
    2022-04-22T13:49:40.897+00:00
    $a = get-netadapter -name "ethernet"
    $a.MacAddress
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Salvo Gallitano 21 Reputation points
    2022-04-22T13:54:30.647+00:00

    right!
    Why do not i thing first?!
    i tried to do it but i did not delete format-list.

    Great!
    Thanks!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.