VMware Cloud Community
antoniogemelli
Hot Shot
Hot Shot

Script to get memory, cpu and disk allocate

Hello, Can you suggest a script to get in csv file list of virtual machine, with cpu,memory and disk allocate and in which host they are. Thanks

Tags (1)
6 Replies
LucD
Leadership
Leadership

You mean something like this?

Get-VM |

Select Name,@{N='VMHost';E={$_.VMHost.Name}},

    NumCpu,MemoryGB,UsedSpaceGB |

Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

vijayrana968
Virtuoso
Virtuoso

A simple straight one liner would be like this.

Connect-VIServer 'YourvCenterName'

Get-VM | Export-Csv -path “c:\reports\vminventory.csv” –NoTypeInformation

This will export all information regarding VM into CSV file and you can use filter to exclude information you dont want.

If you are looking for specific information you mentioned, use below command :

Connect-VIServer 'YourvCenterName'

Get-VM | select Name, NumCpu, MemoryGB, HardDisks, Host | Export-Csv -path “c:\reports\vminventory.csv” -NoTypeInformation

LucD
Leadership
Leadership

Afaik there are no HardDisks nor Host properties anymore on a VirtualMachine​ object since PowerCLI 5.0.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

antoniogemelli
Hot Shot
Hot Shot

Thanks a lot for explanation, very useful for newbie like me.

Reply
0 Kudos
vijayrana968
Virtuoso
Virtuoso

Thanks LucD​ for correction as always Smiley Happy

Yes I checked these properties are depreciated, and its working with :

Get-VM | select Name, NumCpu, MemoryGB, ProvisionedSpaceGB, UsedSpaceGB, VMHost | Export-Csv -path “c:\reports\vminventory.csv” -NoTypeInformation

Whereas :

ProvisionedSpaceGB = Hard disk space allocated as VMDK.

UsedSpaceGB = Actual Space used inside VMDK

antoniogemelli
Hot Shot
Hot Shot

Thanks LucD and vijayrana968 for help.

Reply
0 Kudos