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 | 3,706 views | 10/07/2014 15:43

You may need to see passthrough disk information from Hyper-V VMs on several clusters.

So you can use following script:

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
30
31
32
33
34
35
36
37
38
39
# Get Clusters
$Clusters = Get-Content Clusters.txt
 
foreach ($Cluster in $Clusters)
{
	# Get Cluster Nodes
	$ClusterNodes = Get-Cluster $Cluster | Get-ClusterNode
 
	foreach ($ClusterNode in $ClusterNodes)
	{
		# Clear PT Values
		$PTDisks = $Null;
 
		# Get Passthrough Disks
		$PTDisks = Get-VM -ComputerName $ClusterNode | Get-VMHardDiskDrive | Where Path -like Disk*
 
		if ($PTDisks)
		{
			# Get VM Name
			$VMName = $PTDisks[0].VMName
 
			# Informational Output
			Write-Host Working on $VMName..
 
			foreach ($PTDisk in $PTDisks)
			{
				# Get Passthrough Disk Info
				$PTInfo = $PTDisk.Path
 
				# Informational Output
				Write-Host $PTInfo
			}
 
			# Informational Output
			Write-Host " "
			Write-Host " "
		}
	}
}

That will give you disk information output. You should add all clusters names into Cluster.txt file.