search
Categories
Archive
Blogroll

Badges

Microsoft PowerShell MVP
MCSE
Sponsors

VirtualMetric
Cozumpark Bilisim Portali
Generating reports of VMs with Dynamic Disk
Posted in Virtual Machine Manager, Windows Powershell, Windows Server | No Comment | 440 views | 22/08/2013 10:12

This is pretty cool and detailed report for VMs with Dynamic Disk. It requires SCVMM 2012 to get details but it’s possible to change it to use Hyper-V PowerShell Cmdlet.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$VMs = Get-VM
foreach ($VM in $VMs)
{
	$Disks = Get-VM $VM | Get-SCVirtualHardDisk
	foreach ($Disk in $Disks)
	{
		if ($Disk.VHDType -ne "FixedSize")
		{
			$DiskLocation = $Disk.Location
			$CSVVolume = ($Disk.Location.Split("\"))[2]
			$DiskName = ($Disk.Location.Split("\"))[-1]
			$DiskSize = ([math]::round(($Disk.Size/1GB), 0))
			$DiskMSize = ([math]::round(($Disk.MaximumSize/1GB), 0))
			$DiskHost = $Disk.VMHost
			$CSVFreeSpace = ([math]::round(((Get-SCStorageVolume | where VMHost -eq $DiskHost | Where Name -like "*$CSVVolume*").FreeSpace/1GB), 0))
			$CSVCapacity = ([math]::round(((Get-SCStorageVolume | where VMHost -eq $DiskHost | Where Name -like "*$CSVVolume*").Capacity/1GB), 0))
			$Value = $VM.Name + ";" + $DiskName + ";" + $CSVVolume + ";" + $CSVFreeSpace + ";" + $CSVCapacity + ";" + $DiskMSize + ";" + $DiskSize + ";" + $DiskHost
			Add-Content -Path DiskUsage.txt -Value $Value
		}
	}
}

It also shows CSV volume name, capacity and free space information.



Leave a Reply