Export the list of virtual machines to a CSV file

Here is the script to collect vmware virtual machines details and export to an excel (.csv) using  vSphere PowerCLI commands. This will help Vmware administrator to take a report of Memory, CPU usage,  Data store, HDD space allocation, Host server, Guest OS etc..  here we are using command “get-vm” and “Select-Object” to filter the properties of virtual machine

How to connect to Vcenter/ESXi Server

First you have to connect to the vmware server. It can be a ESXi server or a Vcenter

PowerCLI C:\> Connect-VIServer

It will prompt the server address.

cmdlet Connect-VIServer at command pipeline position 1
Supply values for the following parameters:
Server[0]:

Enter the IP address and hit ENTER

Then a new window will prompt from authentication credentials of the VMware server

Export VM list

Once you connected to the server, you can run VM commands to get the output, Following script will give you a list of guest servers with Name of the virtual machine, Number of CPU, Memory, Disk Space

Get-VM | Select-Object Name, NumCPU, MemoryMB, ProvisionedSpaceGB | Export-Csv "Report.csv"

Find the list of List of VM Property Names here.  you can use this names after “select-object” . separated by comma

Use “out-gridview” instead of “Export-Csv“ to get a sample output. See the figure

About Albin Sebastian

I am a Technology Blogger, System Administrator by profession and webmaster by passion. Technology blogger, Active in Online and offline tech communities.

Check Also

hp_moonshot_1500_chassis thumb

HP Moonshot System – Atom-based Servers from HP

HP launches first Atom-based Moonshot servers. It is a blade server kind of concept with …