VMware Cloud Community
koshary
Contributor
Contributor

get the smallest VM disk size on the cluster and power it on

I've a cluster with more than 1000 VM , Some of those VMs are power off due to lack of capacity 

i need to list all powerdoff VMs and select the smallest disk sizeand power on this VM 

Connect-VIServer vcsa.domain.local -User userl -Password password

$Report = @()

$VMs = Get-Cluster  "Cluster" |
get-vm |Where-object {$_.powerstate -eq "poweredoff"}

foreach ($vm in Get-VM){ get-harddisk  ??

how to compare between total disk size of all VMs to get the lowest disk size ?

0 Kudos
3 Replies
LucD
Leadership
Leadership

Try something like this

Get-Cluster  "Cluster" | 
Get-VM |Where-object {$_.PowerState -eq "poweredoff"} |
Sort-Object -Property ProvisionedSpaceGB -Descending |
Select -First 1


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

0 Kudos
koshary
Contributor
Contributor

Thanks LucD 

ProvisionedSpaceGB is not accurate , i used sum of HardDiskSizeGB and it worked fine.

another question if you could help 

how can i enable logging for specifc VM before power it on ?

0 Kudos
LucD
Leadership
Leadership

"... ProvisionedSpaceGB is not accurate"?

That depends what number you want to see?


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

0 Kudos