I want to use this blog to post answers to common and/or complex questions I get asked about Workflow Studio. One that has been asked fairly often is how to access the MAC address of a VM running in XenServer. The MAC address for a VM is located in the following object path:

VMList.VM.VirtualInterfaces.MAC

When you call Get-VM you get back a list that represents multiple VMs. Whenever you are dealing with something that returns more than one item in Workflow Studio you are going to need to access the individual items with the “For Each Object” task. As you iterate over this list of VMs you will have a new object that represents an individual VM. This typically has properties on it that you want to access, but in this case there is another list of things named “VirtualInterfaces”. Because a given VM can be assigned multiple network cards we have an object that represents each of them, so we need to go down one more level using the “For Each Object Task” to get an individual Virtual Interface so we can access the MAC property. I hope that is clear, but since pictures speak more clearly here is an example:

At the top of the workflow you would call Get-VM and then use For Each Object to iterate over each one returned:


 

 You will notice that the For Each task has the little (s) icon representing it has sub-tasks, so if you double-click on that task you will be able to specify the sub-tasks where you will iterate again on the Virtual Interfaces:






And  then you can access the individual MAC address:

Hopefully that clears up how to get to the MAC address of a VM.