-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVMM2012_CheckClusterNetwork.ps1
More file actions
133 lines (133 loc) · 4.61 KB
/
Copy pathVMM2012_CheckClusterNetwork.ps1
File metadata and controls
133 lines (133 loc) · 4.61 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#-------------------------------------------------
#Finds Why HA network is not reported as HA by VMM
#This script is provided by the SCVMM Product Team 'as-is' and you use it at your own risk
#-------------------------------------------------
function CompareList($list1, $list2)
{
if( $list1.count -ne $list2.count )
{
return $false
}
for($ndx = 0; $ndx -lt $list1.count ; $ndx++)
{
if( $list1[$ndx].ToString() -ne $list2[$ndx].ToString() )
{
return $false
}
}
return $true
}
function ValidateHANetwork($clusterName, $switchName)
{
$validationResult = $true
$cluster = get-scvmhostcluster -name $clusterName
$vNic = Get-SCVirtualNetwork -VMHost $cluster.nodes[0] | where {$_.name -eq $switchName}
if( $vNic -eq $null )
{
Write-Host "Virtual Switch not found in host " $cluster.nodes[0].Name
$validationResult = $false
}
else
{
if( $vNic.VMHostNetworkAdapters.Count -eq 0 )
{
Write-Host "Virtual Switch not attached to external network card on host " + $cluster.nodes[0].Name
$validationResult = $false
}
else
{
foreach($node in $cluster.nodes)
{
Write-Host "==========================================================================="
Write-Host "Comparing " $node.Name
Write-Host "==========================================================================="
$vNicToCompare = Get-SCVirtualNetwork -VMHost $node | where {$_.name -eq $switchName}
if( $vNicToCompare -eq $null )
{
$validationResult = $false
Write-Host "Virtual Switch not found in host " $node.Name
}
if( $vNicToCompare.VMHostNetworkAdapters.Count -eq 0)
{
$validationResult = $false
Write-Host "Virtual Switch not attached to external network card on host " $node.Name
}
if( $vNic.VMHostNetworkAdapters[0].LogicalNetworks -eq $null )
{
if( $vNicToCompare.VMHostNetworkAdapters[0].LogicalNetworks -ne $null )
{
$validationResult = $false
Write-Host "Net Adapter " $vNic.VMHostNetworkAdapters.Name " for " $cluster.nodes[0].name " is not connected to logical network but Net adapter " $vNicToCompare.VMHostNetworkAdapters.Name " for " $node.Name
}
}
else
{
$ln1 = @($vNic.VMHostNetworkAdapters[0].LogicalNetworks | Sort-Object Name)
$ln2 = @($vNicToCompare.VMHostNetworkAdapters[0].LogicalNetworks | Sort-Object Name)
$ln1Id = @($vNic.VMHostNetworkAdapters[0].LogicalNetworks | Sort-Object ID | select ID)
$ln2Id = @($vNicToCompare.VMHostNetworkAdapters[0].LogicalNetworks | Sort-Object ID | select ID)
$result = CompareList $ln1Id $ln2Id
if( $result -eq $false )
{
Write-Host "Logical Networks on Adapters don't match"
Write-Host "------------------------------------------------"
Write-Host "Host " $cluster.nodes[0].name " Logical networks for adapter " $vNic.VMHostNetworkAdapters[0].Name
@($ln1) | ft *
Write-Host "------------------------------------------------"
Write-Host "Host " $node.name " Logical networks for adapter " $vNicToCompare.VMHostNetworkAdapters[0].Name
@($ln2) | ft *
Write-Host "------------------------------------------------"
$validationResult = $false
}
else
{
$sub1 = @($vNic.VMHostNetworkAdapters[0].SubnetVLans | Sort-Object Name)
$sub2 = @($vNicToCompare.VMHostNetworkAdapters[0].SubnetVLans | Sort-Object Name)
$sub1Id = @($vNic.VMHostNetworkAdapters[0].SubnetVLans | Sort-Object ID | select ID)
$sub2Id = @($vNicToCompare.VMHostNetworkAdapters[0].SubnetVLans | Sort-Object ID | select ID)
$result = CompareList $sub1Id $sub2Id
if( $result -eq $false )
{
Write-Host "Subnets on Adapters don't match"
Write-Host "------------------------------------------------"
Write-Host "Host " $cluster.nodes[0].name " Subnets"
@($sub1) | ft *
Write-Host "------------------------------------------------"
Write-Host "Host " $node.name " Subnets"
@($sub2) | ft *
Write-Host "------------------------------------------------"
$validationResult = $false
}
else
{
if( $vNic.VMHostNetworkAdapters[0].VLanMode -ne $vNicToCompare.VMHostNetworkAdapters[0].VLanMode )
{
Write-Host "VlanModes on Adapters don't match"
Write-Host "------------------------------------------------"
Write-Host "Host " $cluster.nodes[0].name " Subnets"
$vNic.VMHostNetworkAdapters[0].VLanMode
Write-Host "------------------------------------------------"
Write-Host "Host " $node.name " Subnets"
$vNicToCompare.VMHostNetworkAdapters[0].VLanMode
Write-Host "------------------------------------------------"
$validationResult = $false
}
}
}
}
}
}
}
return $validationResult
}
if ($args.Length -ne 2 )
{
Write-Host "Usage: CheckClusterNetwork <clusterName> <switchName>"
}
else
{
$result = ValidateHANetwork $args[0] $args[1]
if( $result -eq $true)
{
Write-Host "The cluster virutal network is HA and is configured correctly"
}