Retrieving Virtual Machine Templates as vSphere View Objects

It is possible to retreive virtual machine template information using the Get-View cmdlet, by retrieving VirtualMachine type objects based on the property value that describes the object as a template to which the value is returned as a boolean value.

To retrieve VirtualMachine objects , the property value we require to retrieve is Config.Template where the value is ‘True’, which can be achieved as follows:

Get-View -ViewType VirtualMachine -Property Name, Config.Template | Where-Object {$_.Config.Template -eq "True"}

In my example, I required not to include virtual machine templates in the collection of VirtualMachine objects and there selecting only objects where the property value was not equal to ‘True’.

Get-View -ViewType VirtualMachine -Property Name, Config.Template | Where-Object {$_.Config.Template -ne "True"}

For the Property value I am specifying only the Name and Config.Template properties of the view object as this is only what I require, but in your use case you may want to extend the properties retrieved.


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 )

Twitter picture

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

Facebook photo

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

Connecting to %s