-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compare-EsxImageProfilePlus.ps1
117 lines (95 loc) · 3.6 KB
/
Compare-EsxImageProfilePlus.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
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
function Compare-EsxImageProfilePlus{
<#
.SYNOPSIS
Compare two EsxImageProfile.
Based on "Compare-EsxImageProfile" but with a simpler output.
.DESCRIPTION
Compare two EsxImageProfile.
Based on "Compare-EsxImageProfile" but with a simpler output.
.NOTES
Author: Christophe Calvet
Blog: http://www.thecrazyconsultant.com/
.PARAMETER ReferenceProfile
Specifies the reference image profile for comparison.
.PARAMETER ComparisonProfile
The image profile to compare against.
.PARAMETER IncludeVibInOutput
Add the Vib in the output table. Only useful if extra information need to be extracted.
.EXAMPLE
#The standard output list Vib Name, Vendor And Version for both the source and destination profile, and the analysis.
Compare-EsxImageProfilePlus $ImageProfile1 $ImageProfile2 | select * | ogv
#The switch IncludeVibInOutput is used to extra more information like CreationDate or Description in the example below.
Compare-EsxImageProfilePlus $ImageProfile1 $ImageProfile2 -IncludeVibInOutput | select Name,VendorRef,VersionRef,@{N="CreationDateRef";E={$_.VibRef.CreationDate}},@{N="DescriptionRef";E={$_.VibRef.Description}},VendorComp,VersionComp,@{N="CreationDateComp";E={$_.VibComp.CreationDate}},@{N="DescriptionComp";E={$_.VibComp.Description}},Analysis | ogv
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[VMware.ImageBuilder.Types.ImageProfile]$ReferenceProfile,
[Parameter(Mandatory=$true)]
[VMware.ImageBuilder.Types.ImageProfile]$ComparisonProfile,
[switch]$IncludeVibInOutput
)
process{
$ViblistReferenceProfile = ($ReferenceProfile.viblist)
$ViblistComparisonProfile = ($ComparisonProfile.viblist)
$ListOfAllVib = $ViblistReferenceProfile + $ViblistComparisonProfile
$CompareResult = Compare-EsxImageProfile $ReferenceProfile $ComparisonProfile
$UpgradeFromRef = $CompareResult.UpgradeFromRef
$DowngradeFromRef = $CompareResult.DowngradeFromRef
$VibNameUpgradeFromRef = $UpgradeFromRef | foreach-object{
$VibName = $_ -replace ('.*bootbank_','') -replace ('.*re_locker_','') -replace ('_.*','')
$VibName
}
$VibNameDowngradeFromRef = $DowngradeFromRef | foreach-object{
$VibName = $_ -replace ('.*bootbank_','') -replace ('.*re_locker_','') -replace ('_.*','')
$VibName
}
$ListOfAllVib | select -unique Name | foreach-object {
$Name = $_.Name
$Analysis = "NotTested"
$VibRef = ($ViblistReferenceProfile | where {$_.Name -eq $Name})
$VibComp = ($ViblistComparisonProfile | where {$_.Name -eq $Name})
If (($VibRef -and !$VibComp )){
$Analysis = "OnlyInRef"
}
If ((!$VibRef -and $VibComp )){
$Analysis = "OnlyInComp"
}
If (($VibRef -and $VibComp)){
If (($VibRef.version) -eq ($VibComp.version)){
$Analysis = "Identical"
}
if ($Name -in $VibNameUpgradeFromRef){
$Analysis = "UpgradeFromRef"
}
if ($Name -in $VibNameDowngradeFromRef){
$Analysis = "DowngradeFromRef"
}
}
if($IncludeVibInOutput){
$Result = New-Object -Type PSObject -Prop ([ordered]@{
'Name' = $Name
'VendorRef' = $VibRef.Vendor
'VersionRef' = $VibRef.Version
'VibRef' = $Vibref
'VendorComp' = $VibComp.Vendor
'VersionComp' = $VibComp.Version
'VibComp' = $VibComp
'Analysis' = $Analysis
})
Return $Result
}
Else{
$Result = New-Object -Type PSObject -Prop ([ordered]@{
'Name' = $Name
'VendorRef' = $VibRef.Vendor
'VersionRef' = $VibRef.Version
'VendorComp' = $VibComp.Vendor
'VersionComp' = $VibComp.Version
'Analysis' = $Analysis
})
Return $Result
}
}
}
}