Author Posts

November 13, 2014 at 8:13 am

Hi All

I have the following xml element:

class XmlElement
type = bytes
#text = ABVdZBRW


I've been trying to convert the #text value to a MAC address, without much success. The closest I got was:

$mac = "ABVdZBRW"
$bytes = [System.Text.Encoding]::UTF8.GetBytes[$mac]

which is obviously wrong!

The value [i]should[/i] convert to [b]00-15-5D-64-14-56[/b]... If it helps – the element is from a Legacy Network Adapter section in a Hyper-V virtual machine config file!



November 13, 2014 at 8:25 am

The problem is that you're treating that string as though it is UTF8. It's actually the MAC address in base64-encoded form:

$base64 = "ABVdZBRW"
$bytes = [System.Convert]::FromBase64String($base64)

November 13, 2014 at 8:32 am

Well – that is my ignorance showing through, now immortalized for all time on this message board! 🙂

Your version works perfectly – thanks a lot!!!


November 13, 2014 at 8:37 am

Showing ignorance isn't a bad thing. 🙂 (See: [url=""]Apprenticeship Patterns[/url] )