PowerCLI

 View Only
  • 1.  What are all the objects that can be queried for a VM?

    Posted Mar 09, 2011 02:41 AM

    What is the current list of retrievable objects related to a VM?  Would a complete list be obtainable through a single query, or would multiple queries be required?

    I saw a similar thread on VM Inventory (Need Powershell script for VM inventory), with specific set of details needed per VM.  I have a spreadsheet of applications and criticality levels, and would like to periodically extract all VM objects into that spreadsheet.  This way I can see the relationship of all VMs grouped by datacenter, cluster, application, criticality, etc.

    Thanks for any pointers!



  • 2.  RE: What are all the objects that can be queried for a VM?

    Posted Mar 09, 2011 06:01 AM

    Not sure exactly what you mean.

    If you mean all the properties that are available from a VirtualMachineImpl object (the object a Get-VM returns), you can do

    Get-VM MyVM | Get-Member

    This will show you all the properties and methods that are available.

    If you mean, in which other cmdlets can you use the VirtualMachineImpl object, then go the Online Reference and select All Parameters and scroll down till you reach the VM parameter.

    You can of course also do this with PowerShell


    Get-Command -Module VMware.VimAutomation.Core | where {$_.Parameters.ContainsKey("VM")} | Select Name


  • 3.  RE: What are all the objects that can be queried for a VM?

    Posted Mar 09, 2011 07:55 AM

    Thanks Luc, 'Get-VM MyVM | Get-Member -MemberType properties' does show properties.  But those are just a few of the parent objects.  Besides detail of each of the properties, I see script magic can get info on such things as ThinDisk Provisioning, SIOC, ObservedIPRange, etc..  I wonder if there's a complete list of known properties that can be gathered from vCenter, even if there's no default query in PowerCLI.



  • 4.  RE: What are all the objects that can be queried for a VM?

    Posted Mar 09, 2011 08:06 AM

    There are in fact 2 worlds living in PowerCLI.

    You have the regular objects that are returned by the PowerCLI cmdlets, like for example the VirtualMachineImpl object that is returned by the Get-VM cmdlet.

    But you also have access to a view to all the vSphere objects, as a read-only copy, through the Extensiondata property (or alternatively through the Get-View cmdlet. These objects are all described in the VMware vSphere API Reference Documentation.

    And most of the script magic uses these objects to manipulate stuff that is not available through the regular PowerCLI objects and cmdlets.



  • 5.  RE: What are all the objects that can be queried for a VM?

    Posted Mar 10, 2011 10:58 PM

    Thanks LucD, you answered my question.  The previously listed get-vm command lists 35 properties, and the API lists an additional set of properties (hundreds).

    http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/api_versions_all_index.html

    I wish it was a bit easier to list methods and get properties though.



  • 6.  RE: What are all the objects that can be queried for a VM?

    Posted Mar 11, 2011 08:02 PM

    Just a short command string for those who want top level parent and child properties for their VMs.

    get-vm | select-object * | export-csv "c:\vm.csv"

    This will collect data into columns for the following:

    PowerState, Version, Description, Notes, Guest, NumCpu, MemoryMB, HardDisks, NetworkAdapters, UsbDevices, CDDrives, FloppyDrives, Host, HostId, VMHostId, VMHost, VApp, FolderId, Folder, ResourcePoolId, ResourcePool, PersistentId, UsedSpaceGB, ProvisionedSpaceGB, DatastoreIdList, HARestartPriority, HAIsolationResponse, DrsAutomationLevel, VMSwapfilePolicy, VMResourceConfiguration, CustomFields, ExtensionData, Id, Name, Uid