When I try to apply a round function to the custom properties in this report, the value is blank. When I take the rounding function off, it works. Any ideas?
$report = Get-VM -Name acme* -server $vcenter |
select name,
ProvisionedSpaceGB,
@{N="vCenterServer";E={$_.Uid.Split(":")[0].Split("@")[1]}},
@{n="Cluster";E={
$rp = Get-View $_.ExtensionData.ResourcePool
$parent = Get-View $rp.Parent
While ($parent -isnot [VMware.Vim.ClusterComputeResource]){
$parent = Get-View $parent.Parent
}
$parent.Name
}} | sort-object vCenterServer |
Group-Object -Property {$_.Cluster} | Select @{n="ClusterName";E={$_.Name}},
@{N="vCenterServer";E={$vcenter.Name}},
@{N="VMCount";E={(get-vm -location $_.Name).count}},
@{N="AcmeVMCount";E={$_.Group | Measure-Object | Select -ExpandProperty Count}},
@{N="VMsPerAcmeVM";E={math::[round](((get-vm -location $_.Name).count / ($_.Group | Measure-Object | Select -ExpandProperty Count)),1)}},
Hello, TheVMinator-
That is probably due to having the syntax slightly off. The square brackets (for the type accelator) go around the .NET class name ("Math" in this case), instead of around the name of the static method from the class ("Round" in this case). So, that should be like:
...
@{N="VMsPerAcmeVM";E={[Math]::round(((get-vm -location $_.Name).count / ($_.Group | Measure-Object | Select -ExpandProperty Count)),1)}}
That do better for you?
Hello, TheVMinator-
That is probably due to having the syntax slightly off. The square brackets (for the type accelator) go around the .NET class name ("Math" in this case), instead of around the name of the static method from the class ("Round" in this case). So, that should be like:
...
@{N="VMsPerAcmeVM";E={[Math]::round(((get-vm -location $_.Name).count / ($_.Group | Measure-Object | Select -ExpandProperty Count)),1)}}
That do better for you?
Perfect - thanks again