Here is a way how to quickly determine the machine type to be deployed without resorting to the ‘VirtualMachineExt’ object (which by the way is not yet available in the ‘BuildingMachine’ state):

# $vm is a VirtualMachine entity
PS > $vm.GetType().FullName
DynamicOps.ManagementModel.VirtualMachine
PS > $vm.MachineType
0
PS > [DynamicOps.ManagementModel.Common.Enums.MachineTypeT].GetEnumName($vm.MachineType)
Virtual
# Check if machine is a Virtual Machine
if([DynamicOps.ManagementModel.Common.Enums.MachineTypeT]::Virtual.value__ -eq $vm.MachineType) {
  # do something
} else {
  # do something else
} # if

In case you wonder what other machine types exist you can check the enumeration like this:

PS > [DynamicOps.ManagementModel.Common.Enums.MachineTypeT].GetEnumNames()
Virtual
Physical
Cloud
AppService
vApp

Though this can easily be achieved in a different manner, the point is it is really useful to explore the ‘DynamicOps.ManagementModel.Common’ assembly so you do not have to hard code properties like ‘Virtual’ or ‘__clone_from’ and the like …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.