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

Badges
MCSE
Community

Cozumpark Bilisim Portali
Getting Hyper-V Failover Clusters List via PowerShell
Posted in Virtual Machine Manager, Windows Powershell, Windows Server | 1 Comment | 3,568 views | 16/07/2013 09:23

You can get Cluster names from your Hyper-V host list with following PowerShell 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
# Prepare Cluster Array
$ClusterArray = New-Object System.Collections.ArrayList
$Servers = Get-Content -Path C:\Servers.txt
foreach ($Server in $Servers)
{
	$VMHost = Get-VMHost -ComputerName $Server
	$HyperVFQDN = $VMHost.FullyQualifiedDomainName
	if ($VMHost)
	{
		$ClusterName = (@(Get-Cluster $Server | Get-ClusterGroup | where GroupType -eq "VirtualMachine") | Select-Object -First 1).Cluster.Name
		if ($ClusterName)
		{
			$TestCluster = $ClusterArray.Contains("$ClusterName")
 
			if ($TestCluster -ne $True)
			{
				# Update Cluster Array
				$ClusterArray.Add("$ClusterName") | Out-Null
			}
 
			Write-Host $ClusterName
		}
	}
}

After that you can use your Cluster names to get CSV reports.


Comments (1)

NeWay Technologies – Weekly Newsletter #52 – July 18, 2013 | NeWay

July 20th, 2013
19:00:18

[…] Getting Hyper-V Failover Clusters List via PowerShell – […]



Leave a Reply