This is my query:
Get-Datastore | where{$_.ExtensionData.summary.multiplehostAccess} | where {$_.name -like "XIO*"}
i am getting this output. can any one guide me how i can sum the value for both FreeSpaceGB and CapacityGB.
and show them separably, my basic goal is to sum and have percentage of both columes
This should get you started:
$datastores = Get-DataStore|Where {$_.Name -like "XIO*"}
$sumFree = ($datastores| Measure-Object -Property FreeSpaceGB -Sum).Sum
$sumCap = ($datastores| Measure-Object -Property CapacityGB -Sum).Sum
$pctFree = [math]::Round(($SumFree/$sumCap)*100,2)
This should get you started:
$datastores = Get-DataStore|Where {$_.Name -like "XIO*"}
$sumFree = ($datastores| Measure-Object -Property FreeSpaceGB -Sum).Sum
$sumCap = ($datastores| Measure-Object -Property CapacityGB -Sum).Sum
$pctFree = [math]::Round(($SumFree/$sumCap)*100,2)
thank you very much. i am new to programming.
$pctFree = [math]::Round(($SumFree/$sumCap)*100,2)
what is the purpose of ,2 ?
That's how many decimal places the that the resulting percent will be rounded to.
In this case I rounded to two decimal places.