hi Luc, In the below given script i'm trying to retrive the datastore usage from each cluster by querying the first host of the cluster. The script runs fine. But at last row for each cluster ...
See more...
hi Luc, In the below given script i'm trying to retrive the datastore usage from each cluster by querying the first host of the cluster. The script runs fine. But at last row for each cluster i want a line with total capacity and total used capacity. But since there are hundreds of LUN's for each cluster the total value is so big and so it doesnt not get stored into the variable in proper format. What type of variable do i declare $totalsize and $totalusize as? $dsTab = @{} $clusters = Get-Cluster foreach ($cluster in $clusters) { $vmhosts = $cluster | Get-VMHost $fhost = $vmhosts[0] $esxImpl = $fhost $ds = $esxImpl | Get-Datastore | %{$dsTab[$_.Name] = $_} $esxImpl | Get-VMHostStorage | %{ $_.FileSystemVolumeInfo | %{ $sizeGB = $_.Capacity/1GB $usedGB = ($_.Capacity/1MB - ($dsTab[$_.Name]).FreeSpaceMB)/1KB $usedPerc = $usedGB / $sizeGB $availGB = ($dsTab[$_.Name]).FreeSpaceMB/1KB $ds = Get-View $dsTab[$_.Name].Id $_ | select @{N="ESX Name";E={$esxImpl.Name}}, @{N="Cluster Name";E={$cluster}}, @{N="FS Name";E={$_.Name}}, @{N="Type";E={$_.Type}}, @{N="SizeGB";E={"{0:N1}" -f $sizeGB}}, @{N="UsedGB";E={"{0:N1}" -f $usedGB}}, @{N="AvailableGB";E={"{0:N1}" -f $availGB}}, @{N="Used%";E={"{0:P1}" -f $usedPerc}}, @{N="Mount point";E={$_.Path}} $totalsize += ($totalsize + $sizeGB) $totalusize += ($totalusize + $usedGB) } $totalsize $totalusize } }