search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell, Windows Server | No Comment | 1,648 views | 09/07/2013 15:56

You can get all passthrough disks and total disk counts like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$Servers = Get-Content C:\Servers2.txt
foreach ($Server in $Servers)
{
	$VMs = Get-VM -ComputerName $Server
	Write-Host $Server
	foreach ($VM in $VMs)
	{
		$Count = 0;
		$TotalDisk = 0;
		$Disks = $VM | Select -Expand HardDrives
		foreach ($Disk in $Disks)
		{
			if ($Disk.Path -like "Disk*")
			{
				$Count++
				[string]$DiskSize = $Disk.Path.Split(" ")[2]
				Write-Host $DiskSize
				$DiskSize = $DiskSize.Split(".")[0]
				$TotalDisk = $TotalDisk + [int]$DiskSize
			}
		}
 
		if ($Count -gt "0")
		{
			$Value = $VM.Name + "," + $Count + "," + $TotalDisk + "," + $VM.ComputerName
			Add-Content -Value $Value -Path C:\passthrough2.txt
		}
	}
}

This will give you sum of all passthrough disks.