Skip to content

Instantly share code, notes, and snippets.

@nshores
Forked from danaugustin/Get Storage Total
Last active June 1, 2018 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nshores/2b0eefb4b7e0beb708c186be9d5ad27a to your computer and use it in GitHub Desktop.
Save nshores/2b0eefb4b7e0beb708c186be9d5ad27a to your computer and use it in GitHub Desktop.
#Create a CSV file with a Column called name containing all your VM names, 1 per line.
$vmlist = import-csv "c:\your\csv\here.csv"
$totaldiskgb = @()
foreach ($vm in $vmlist) {
$disksum = get-vm $vm.name | get-harddisk | Select-Object CapacityGB | Measure-Object CapacityGB -Sum
$totaldiskgb += $disksum.sum
}
$gb = ($totaldiskgb | measure-object -sum).sum
Write-host " Total Size $t GB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment