Hi!
How i can get sum of VCPU of vms from array?
Whats wrong in my script?
$newvms = @(
"myvm01",
"myvm02"
)
Foreach ($newvm in $newvms) {
$report = Get-VM | ? name -Like $newvms*
}
$report | Measure-Object numcpu -Sum
You could do
Get-VM | where{$_.Name -like "myvm*"}
or
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are overwriting $report each time.
Since Get-VM accepts an array on the Name parameter, you can do
"myvm01",
"myvm02"
)
Get-VM -Name $newvms |
Measure-Object -Property NumCpu -Sum
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thx LUCD!
But what about if i wont to use:
-Like $newvms*
?
You could do
Get-VM | where{$_.Name -like "myvm*"}
or
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference