-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Validate-ESXiPackages.psm1
82 lines (66 loc) · 2.6 KB
/
Validate-ESXiPackages.psm1
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
function Validate-ESXiPackages {
<#
.DESCRIPTION
Compares all ESXi Host VIBs within a vSphere with a reference Hosts.
.NOTES
File Name : Validate-ESXiPackages.ps1
Author : Markus Kraus
Version : 1.0
State : Ready
Tested Against Environment:
vSphere Version: 6.0 U2, 6.5 U1
PowerCLI Version: PowerCLI 10.0.0 build 7895300
PowerShell Version: 4.0
OS Version: Windows Server 2012 R2
.LINK
https://mycloudrevolution.com/
.EXAMPLE
Validate-ESXiPackages -Cluster (Get-Cluster) -RefernceHost (Get-VMHost | Select-Object -First 1)
.PARAMETER Cluster
vSphere Cluster to verify
.PARAMETER RefernceHost
The VIB Reference ESXi Host
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, HelpMessage="vSphere Cluster to verify")]
[ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.ComputeResourceImpl] $Cluster,
[Parameter(Mandatory=$True, ValueFromPipeline=$false, HelpMessage="The VIB Reference ESXi Host")]
[ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl] $RefernceHost
)
Process {
#region: Get reference VIBs
$EsxCli2 = Get-ESXCLI -VMHost $RefernceHost -V2
$RefernceVibList = $esxcli2.software.vib.list.invoke()
#endregion
#region: Compare reference VIBs
$MyView = @()
foreach ($VmHost in ($Cluster | Get-VMHost)) {
$EsxCli2 = Get-ESXCLI -VMHost $VmHost -V2
$VibList = $esxcli2.software.vib.list.invoke()
[Array]$VibDiff = Compare-Object -ReferenceObject $RefernceVibList.ID -DifferenceObject $VibList.ID
if($VibDiff.Count -gt 0) {
$VibDiffSideIndicator = @()
foreach ($Item in $VibDiff) {
$VibDiffSideIndicator += $($Item.SideIndicator + " " + $Item.InputObject)
}
}
else {
$VibDiffSideIndicator = $null
}
$Report = [PSCustomObject] @{
Host = $VmHost.Name
Version = $VmHost.Version
Build = $VmHost.Build
VibDiffCount = $VibDiff.Count
VibDiff = $VibDiff.InputObject
VibDiffSideIndicator = $VibDiffSideIndicator
}
$MyView += $Report
}
#region: Compare reference VIBs
$MyView
}
}