-
Notifications
You must be signed in to change notification settings - Fork 1
/
Check-vCoudHostKey.ps1
executable file
·39 lines (33 loc) · 1.03 KB
/
Check-vCoudHostKey.ps1
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
Add-PSSnapin VMware.VimAutomation.Core
# ----------------------
# Specify vCenter Server
# ----------------------
$vc = $env:VCENTER_SERVER
$vi = Connect-VIServer -Server $vc
Write-Host "Connect vCenter : " $vi.IsConnected
$results = @()
foreach ($h in Get-VMHost){
try{
$mp = ($h | Get-EsxCli).vcloud.fence.getfenceinfo() | Select-Object ModuleParameters | Select "ModuleParameters"
$isException = ""
}
catch [Exception]{
$isException = "Exception!!"
}
finally{
if ($mp -match "Host key: (0x0)"){
$hostKey = $Matches[1]
$result = "NG"
}
elseif ($mp -match "Host key: (.+)"){
$hostKey = $Matches[1]
$result = "OK"
}
else{
$hostKey = "0x0"
$result = "NG"
}
$results += [PSCustomObject] @{ "Host" = $h.Name; "Host key" = $hostKey; "Result" = $result; "Exception" = $isException }
}
}
$results | Sort-Object "Host" | ft -AutoSize