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
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
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
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
Thanks LucD that was exactly what I was looking for.