Listing the MDT Variables with Windows Powershell

I was trying to find out Where MDT got all of it’s lovely variables like %SERIALNUMBER% when I stumbled across this Great post from Andrew Barnes on Variables.DAT.

So I popped over and swiped a VARIABLES.DAT file from the WinPE environment and looked at it.   As Andrew stated, it was XML data.  I find reading XML data about as exciting as painting a bathroom wall with a toothbrush.

Yes, not all the enticed about it, am I?

But I DO love playing with Windows Powershell.  And since it can NATIVELY deal with XML files (unless my poor fuzzy human brain) I choose it!

 

So if you’d like an EASIER way to see what variables you have in VARIABLES.DAT to see how you could play about with them, here is an easier way.

[XML]$MDTVars=GET-CONTENT Variables.DAT

$MDTVars.MediaVarList.var.Name

This will dump a list of all the Variable names.  Would you like them sorted?  Sure!

$MDTVars.MediaVarList.var.Name | SORT-OBJECT

“Wait! I want to see the values too!”

(Fussy fussy fussy!)

*poof!*

$MDTVars.MediaVarList.var | SORT-OBJECT

Not anything truly amazing in Powershell but it’s something I found particularly handy today Smile

By the way, Thanks Andrew on that post! Made MY day easier!

Sean
”The Energized Tech”

Leave a Reply