Script to write virtual machine properties into a .csv file

You want to export the properties of some or all virtual machines into a .csv file? Use the Get-VM cmdlet. It helps you to export an inventory of all or some VMs, found in your vCenter to eg. a csv file.

With the following command, you can export dedicated information from all your VMs to a file called c:\mymachines.csv:

connect-viserver your_vCenter

Get-VM | Select-Object Name,Host,NumCPU,MemoryMB,PowerState |

Export-CSV c:\mymachines.csv -NoTypeInformation

If you want to export the properties of only one or more dedicated virtual machines, use the Get-VM -Name “VM1″,”VM2” parameter.

In the following example you will export the properties of two VMs, called VM1 and VM2:

connect-viserver your_vCenter

Get-VM -Name “VM1″,”VM2” | Select-Object Name,NumCPU,MemoryMB,PowerState,Host |

Export-CSV c:\mymachines.csv -NoTypeInformation

Here is a list of some virtual machines properties you want to retrieve:

  • 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
  • Name
  • CustomFields
  • ExtensionData
  • Id
  • Uid

Leave a Comment

Your email address will not be published. Required fields are marked *