2018-12-17

取得 Hyper-V Host 上 VM 的 CPU、Memory、HDD Size 等基本資訊

取得 Hyper-V Host 上 VM 的 CPU、Memory、HDD Size 等基本資訊

$VMs = Get-VM
$Result = "Hyper-V Host,VM Name,CPU Count,Mem Min (MB),Mem Max (MB),HDD Path,HDD FileSize (MB),HDD Size (MB)`r`n";
foreach ($VM in $VMs) {

$CPU = $VM | Get-VMProcessor
$Mem = $VM | Get-VMMemory
$HDDs = $VM | Select-Object VMId | Get-VHD | select path,filesize,size

foreach ($HDD in $HDDs) {
$Result += $env:computername+","+$VM.Name+","+$CPU.Count+","+$Mem.Minimum/1024/1024+","+$Mem.Maximum/1024/1024+","+$HDD.path+","+$HDD.filesize/1024/1024+","+$HDD.size/1024/1024+"`r`n";
};
};
$Result | Out-File -filepath "$env:computername VMs.txt"

沒有留言:

張貼留言