Last active
October 3, 2018 09:26
-
-
Save mczerniawski/0d5f252eacbb411bedc09e0a647e46d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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