VMware Cloud Community
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

Need total amount of powered off vm's....

Sorry if this is a stupid question but I am new to powershell. I need to be able to list the total amount of powered off vm's per cluster, can I do that using VI Toolkit and if so how? Thanks for any help.

Jason

Jason @jrob24
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure you can. Try this

Get-Cluster | Select-Object Name, @{Name="#PoweredOff"; Expression={($_ | Get-VM | Where-Object {$_.PowerState -eq "PoweredOff"} |Measure-Object).count}}


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Sure you can. Try this

Get-Cluster | Select-Object Name, @{Name="#PoweredOff"; Expression={($_ | Get-VM | Where-Object {$_.PowerState -eq "PoweredOff"} |Measure-Object).count}}


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

0 Kudos
dzi-icoma
Contributor
Contributor
Jump to solution

you can use that host script with PowerScripter (www.icomasoft.com/powerscripter ) within VMware VI client on any host or cluster object to get a host list and total with PoweredOff VMs count:

#--multi

$report = @()

$sum = 0;

$multi | % {

$row = "" | Select-Object Host, PoweredOff

$server = $_

$row.Host = $server.Name

$row.PoweredOff = ($server | get-vm | Where-Object {$_.PowerState -eq "PoweredOff"} | Measure-Object).count

$report += $row

$sum += $row.PoweredOff

}

$report

""

"Total PoweredOff: " + $sum.ToString()

Regards,

Dennis

PowerScripter - customize VI client or VirtualCenter http://powerscripter.net
0 Kudos
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

Thanks LucD that was exactly what I was looking for.

Jason @jrob24
0 Kudos