Skip to content

Instantly share code, notes, and snippets.

@mczerniawski
Last active October 3, 2018 09:26
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 mczerniawski/0d5f252eacbb411bedc09e0a647e46d7 to your computer and use it in GitHub Desktop.
Save mczerniawski/0d5f252eacbb411bedc09e0a647e46d7 to your computer and use it in GitHub Desktop.
$HyperVHosts = @('Cluster1','Node1','Node2')
$VMs = Get-VM -ComputerName $HyperVHosts | ForEach-Object {
Write-Host "Procesing VM {$($PSItem.VMName)}"
Write-Host "Getting VM {$($PSItem.VMName)} disk information"
$disks = Get-VHD -VMId $PSItem.VMId -ComputerName $PSItem.ComputerName
$diskCount = $disks | Measure | Select-Object -ExpandProperty Count
$diskCurrentSize = $disks | Measure-Object -Sum -Property FileSize | Select-Object -ExpandProperty Sum
$diskMaximumSize = $disks | Measure-Object -Sum -Property Size | Select-Object -ExpandProperty Sum
[pscustomobject]@{
Name = $PSItem.Name
ComputerName = $PSItem.ComputerName
MemoryMinimum = [System.Math]::Round($PSItem.MemoryMinimum /1GB,2)
MemoryMaximum = [System.Math]::Round($PSItem.MemoryMaximum /1GB,2)
MemoryAssigned = [System.Math]::Round($PSItem.MemoryAssigned /1GB,2)
ProcessorCount = $PSItem.ProcessorCount
DisksCount = $diskCount
DiskCurrentSize = [System.Math]::Round($diskCurrentSize /1GB,2)
DiskMaximumSize = [System.Math]::Round($diskMaximumSize /1GB,2)
CreationTime = $PSItem.CreationTime
}
}
$VMs | Format-Table -Wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment