Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$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
You can’t perform that action at this time.