-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathESXi-Upgrade-ReadinessCheck.ps1
More file actions
2707 lines (2372 loc) · 108 KB
/
Copy pathESXi-Upgrade-ReadinessCheck.ps1
File metadata and controls
2707 lines (2372 loc) · 108 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
.SYNOPSIS
ESXi-Upgrade-ReadinessCheck.ps1 - Comprehensive ESXi host upgrade readiness assessment tool
.DESCRIPTION
Performs a detailed analysis of ESXi hosts to determine their readiness for upgrading to a target ESXi version.
This script evaluates multiple critical factors including:
- CPU compatibility with target ESXi version
- Storage capacity and configuration
- Current ESXi version and upgrade path requirements
- Overall system readiness
The results are presented in both a detailed CSV file and an interactive HTML report that clearly
categorizes hosts as:
- Ready for Upgrade: Hosts that meet all requirements for direct upgrade
- Already Up-To-Date: Hosts already running the target version or latest build
- Not Ready: Hosts with specific issues preventing upgrade (with detailed explanations)
- Failed to Check: Hosts that could not be properly assessed (with error details)
The HTML report includes filtering capabilities, detailed host information, and visual indicators
to help plan and prioritize your ESXi upgrade strategy.
.PARAMETER Help
Displays this help message.
.PARAMETER Servers
One or more server hostnames or IP addresses to check.
Example: -Servers "esxi01.domain.com","esxi02.domain.com"
.PARAMETER ServerListFile
Path to a CSV file containing a list of servers. The script looks for a column named "Host Name"
or any valid alias (e.g., hostname, host) to find ESXi hosts. Optionally can include an IP column
under "IP", "IPAddress", or "IP Address".
Example: -ServerListFile "C:\Inventory\servers.csv"
.PARAMETER NameMatch
Optional string used to filter servers by partial hostname match (e.g., only include servers with "ESX" or "LAB").
If not specified, all valid rows are processed.
Example: -NameMatch "ESX"
.PARAMETER OutputCsv
Path to a CSV file where results are saved.
Default: "ESXi-Upgrade-Results-[timestamp].csv"
.PARAMETER ReportPath
Path to save HTML summary report with interactive filtering and detailed host information.
Default: "ESXi-Upgrade-Report-[timestamp].html"
.PARAMETER UpgradeVersion
Target ESXi version for upgrade assessment.
Default: "8.0.3" (pulls from config.json if not specified)
.PARAMETER Parallel
Process hosts in parallel using PowerShell jobs for faster execution.
Recommended for checking large numbers of hosts.
.PARAMETER MaxConcurrentJobs
Maximum number of concurrent jobs when using parallel processing.
Default: 5
.EXAMPLE
PS> .\ESXi-Upgrade-ReadinessCheck.ps1 -Servers "esxi01.domain.com","esxi02.domain.com" -OutputCsv "results.csv"
Checks the specified servers and saves results to "results.csv"
.EXAMPLE
PS> .\ESXi-Upgrade-ReadinessCheck.ps1 -ServerListFile "servers.csv" -Parallel -MaxConcurrentJobs 10
Processes all ESXi hosts in the CSV file in parallel with 10 concurrent jobs maximum
.EXAMPLE
PS> .\ESXi-Upgrade-ReadinessCheck.ps1 -ServerListFile "servers.csv" -NameMatch "CHQ"
Only checks servers whose hostnames contain "CHQ"
.EXAMPLE
PS> .\ESXi-Upgrade-ReadinessCheck.ps1 -ServerListFile "servers.csv" -UpgradeVersion "8.0.3"
Assesses all hosts against ESXi 8.0.3 requirements specifically
.NOTES
Author: Roy Dawson IV
Github: https://github.com/ImYourBoyRoy
Version: 2.1
Last Updated: April 2025
REQUIREMENTS:
- VMware PowerCLI
- Configuration is read from config.json in the same folder (optional)
CONFIG.JSON FORMAT:
{
"Username": "user@domain.com",
"Password": "SecurePassword",
"TargetESXiVersion": "8.0.3",
"MinimumRequiredSpaceGB": 10,
"MinimumBootbankFreePercentage": 90
}
FEATURES:
- Precise version and build identification
- Detailed CPU compatibility verification
- Storage requirement validation
- Upgrade path determination
- Categorized reporting with actionable recommendations
- Interactive HTML report with filtering capabilities
- Multi-threaded processing for large environments
- Comprehensive logging and error tracking
#>
[CmdletBinding()]
param (
[switch]$Help,
[string[]]$Servers,
[string]$ServerListFile,
[string]$OutputCsv = "ESXi-Upgrade-Results-$(Get-Date -Format 'yyyyMMdd-HHmmss').csv",
[string]$ReportPath = "ESXi-Upgrade-Report-$(Get-Date -Format 'yyyyMMdd-HHmmss').html",
[string]$UpgradeVersion,
[switch]$Parallel,
[int]$MaxConcurrentJobs = 5,
[string]$NameMatch
)
#region Script Initialization and Setup
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$script:GlobalConfig = $null
$script:PowerCLIConfigured = $false
$script:Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$script:LogFile = "ESXi-Upgrade-Log-$(Get-Date -Format 'yyyyMMdd-HHmmss').log"
$script:FailureLogFile = "ESXi-Upgrade-Failures-$(Get-Date -Format 'yyyyMMdd-HHmmss').log"
$script:Summary = @{
TotalHosts = 0
ReadyForUpgrade = 0
NotReadyForUpgrade = 0
FailedToCheck = 0
AlreadyUpToDate = 0
Categories = @{
"Ready" = @()
"CPU Incompatible" = @()
"Storage Issues" = @()
"Requires Intermediate Upgrade" = @()
"Multiple Issues" = @()
"Failed to Check" = @()
"Already Up-To-Date" = @()
}
}
# Display help if requested or if no parameters provided
if ($Help -or (-not $Servers -and -not $ServerListFile)) {
$helpText = @"
ESXi Upgrade Readiness Assessment Tool
======================================
USAGE: ESXi-Upgrade-ReadinessCheck.ps1 [-Help] [-Servers <String[]>] [-ServerListFile <String>]
[-OutputCsv <String>] [-ReportPath <String>] [-UpgradeVersion <String>] [-Parallel] [-MaxConcurrentJobs <Int>]
DESCRIPTION:
Performs a comprehensive ESXi upgrade readiness check with detailed reporting and categorization.
Clearly identifies which hosts can be upgraded to ESXi 8.x and why others cannot.
PARAMETERS:
-Help Displays this help message.
-Servers One or more server hostnames/IPs.
-ServerListFile Path to a CSV file with a 'Host Name' column for ESXi hosts.
-OutputCsv Path to save CSV results. Default: "ESXi-Upgrade-Results-[timestamp].csv"
-ReportPath Path to save HTML report. Default: "ESXi-Upgrade-Report-[timestamp].html"
-UpgradeVersion Target ESXi version. Default: "8.0.3" (or value from config.json)
-Parallel Process hosts in parallel for faster execution.
-MaxConcurrentJobs Maximum concurrent jobs when using parallel processing. Default: 5
EXAMPLES:
.\ESXi-Upgrade-ReadinessCheck.ps1 -Servers "esxi01.domain.com","esxi02.domain.com"
.\ESXi-Upgrade-ReadinessCheck.ps1 -ServerListFile "servers.csv" -Parallel -MaxConcurrentJobs 10
"@
Write-Host $helpText -ForegroundColor Cyan
return
}
#endregion
#region Helper Functions
function Write-Log {
param (
[string]$Message,
[ValidateSet('INFO', 'WARNING', 'ERROR', 'SUCCESS')]
[string]$Level = 'INFO',
[switch]$JobContext
)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$colorMap = @{
'INFO' = 'White'
'WARNING' = 'Yellow'
'ERROR' = 'Red'
'SUCCESS' = 'Green'
}
# Format the message
$formattedMessage = "[$timestamp] [$Level]"
if ($JobContext) {
$formattedMessage += " [Job]"
}
$formattedMessage += " $Message"
# Console output with appropriate color
Write-Host $formattedMessage -ForegroundColor $colorMap[$Level]
# Only write to log file if not in job context
if (-not $JobContext -and $script:LogFile) {
$formattedMessage | Out-File -FilePath $script:LogFile -Append
}
}
function Write-FailureLog {
param (
[string]$HostName,
[string]$Reason,
[string]$IPAddress = "",
[switch]$JobContext
)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logEntry = "$timestamp - Failed to process host: $HostName"
if ($IPAddress) {
$logEntry += " (IP: $IPAddress)"
}
$logEntry += " - Reason: $Reason"
# Only write to failure log file if not in job context
if (-not $JobContext -and $script:FailureLogFile) {
$logEntry | Out-File -FilePath $script:FailureLogFile -Append
}
# Also write to main log
Write-Log -Message "Failed to process host: $HostName - Reason: $Reason" -Level 'ERROR' -JobContext:$JobContext
}
function Initialize-Summary {
$script:Summary.TotalHosts = 0
$script:Summary.ReadyForUpgrade = 0
$script:Summary.NotReadyForUpgrade = 0
$script:Summary.FailedToCheck = 0
$script:Summary.AlreadyUpToDate = 0
$script:Summary.Categories = @{
"Ready" = @()
"CPU Incompatible" = @()
"Storage Issues" = @()
"Requires Intermediate Upgrade" = @()
"Multiple Issues" = @()
"Failed to Check" = @()
"Already Up-To-Date" = @()
}
}
function Format-ByteSize {
param ([double]$Bytes)
$sizes = 'Bytes,KB,MB,GB,TB,PB'
$sizes = $sizes.Split(',')
$index = 0
while ($Bytes -ge 1024 -and $index -lt ($sizes.Count - 1)) {
$Bytes = $Bytes / 1024
$index++
}
return "{0:N2} {1}" -f $Bytes, $sizes[$index]
}
function Write-ProgressUpdate {
param (
[int]$Current,
[int]$Total,
[string]$Status
)
$percentComplete = [math]::Round(($Current / $Total) * 100, 2)
Write-Progress -Activity "ESXi Upgrade Readiness Assessment" -Status $Status -PercentComplete $percentComplete
}
#endregion
#region Configuration and Setup
function Get-Configuration {
if (-not $script:GlobalConfig) {
try {
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "config.json"
if (Test-Path -Path $configPath) {
$json = Get-Content -Path $configPath -Raw | ConvertFrom-Json
Write-Log -Message "Configuration loaded successfully from $configPath" -Level 'INFO'
# Convert Username/Password to PSCredential
$securePassword = ConvertTo-SecureString $json.Password -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential($json.Username, $securePassword)
# Use parameter value if provided, otherwise use config value
$targetVersion = if ($UpgradeVersion) { $UpgradeVersion } else { $json.TargetESXiVersion }
# Create properties with safe access to potentially missing properties
$script:GlobalConfig = [PSCustomObject]@{
Credential = $creds
TargetESXiVersion = $targetVersion
TargetESXiBuild = "24674464" # Updated to include latest build
TargetESXiDetail = "ESXi 8.0.3 Update 3e (Build 24674464)" # Added target version detail
MinimumRequiredSpaceGB = if ((Get-Member -InputObject $json -Name 'MinimumRequiredSpaceGB' -MemberType Properties)) { $json.MinimumRequiredSpaceGB } else { 16 }
MinimumBootbankFreePercentage = if ((Get-Member -InputObject $json -Name 'MinimumBootbankFreePercentage' -MemberType Properties)) { $json.MinimumBootbankFreePercentage } else { 90 }
VendorModelsSupported = if ((Get-Member -InputObject $json -Name 'VendorModelsSupported' -MemberType Properties)) { $json.VendorModelsSupported } else { @() }
}
}
else {
# If config file doesn't exist, prompt for credentials
Write-Log -Message "Config file not found at $configPath, prompting for credentials" -Level 'WARNING'
$creds = Get-Credential -Message "Enter credentials for ESXi hosts"
# Use parameter value if provided, otherwise use default
$targetVersion = if ($UpgradeVersion) { $UpgradeVersion } else { "8.0.3" }
$script:GlobalConfig = [PSCustomObject]@{
Credential = $creds
TargetESXiVersion = $targetVersion
TargetESXiBuild = "24674464" # Latest build
TargetESXiDetail = "ESXi 8.0.3 Update 3e (Build 24674464)"
MinimumRequiredSpaceGB = 16
MinimumBootbankFreePercentage = 90
VendorModelsSupported = @()
}
}
}
catch {
Write-Log -Message "Failed to load configuration: $_" -Level 'ERROR'
throw "Failed to load configuration: $_"
}
}
return $script:GlobalConfig
}
function Initialize-PowerCLI {
if (-not $script:PowerCLIConfigured) {
try {
# Test if PowerCLI is installed
$powerCLIModule = Get-Module -Name VMware.PowerCLI -ListAvailable
if (-not $powerCLIModule) {
Write-Log -Message "VMware PowerCLI module not found. Please install it using: Install-Module -Name VMware.PowerCLI -Scope CurrentUser" -Level 'ERROR'
throw "VMware PowerCLI module not found."
}
# Import VMware modules if not already imported
$requiredModules = @(
'VMware.VimAutomation.Core',
'VMware.VimAutomation.Common'
)
foreach ($module in $requiredModules) {
if (-not (Get-Module -Name $module)) {
Write-Log -Message "Importing module: $module" -Level 'INFO'
Import-Module -Name $module -ErrorAction Stop
}
}
# Configure PowerCLI settings
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false -Confirm:$false | Out-Null
Write-Log -Message "PowerCLI configuration set successfully" -Level 'SUCCESS'
$script:PowerCLIConfigured = $true
}
catch {
Write-Log -Message "Failed to initialize PowerCLI: $_" -Level 'ERROR'
throw "Failed to initialize PowerCLI: $_"
}
}
}
#endregion
#region Host Analysis Functions
function Connect-ESXiHost {
param (
[string]$HostName,
[PSCredential]$Credential,
[string]$IPAddress = ""
)
try {
Write-Log -Message "Attempting connection to host: $HostName" -Level 'INFO'
# Try hostname first
try {
$server = Connect-VIServer -Server $HostName -Credential $Credential -ErrorAction Stop
# Make sure we're returning a single server
if ($server -is [Array]) {
$server = $server[0]
}
Write-Log -Message "Connected to ESXi host $($server.Name)" -Level 'SUCCESS'
return $server
}
catch {
# If hostname fails and IP is provided, try IP address
if ($IPAddress) {
Write-Log -Message "Failed to connect using hostname, trying IP address: $IPAddress" -Level 'WARNING'
$server = Connect-VIServer -Server $IPAddress -Credential $Credential -ErrorAction Stop
# Make sure we're returning a single server
if ($server -is [Array]) {
$server = $server[0]
}
Write-Log -Message "Connected to ESXi host $($server.Name) via IP: $IPAddress" -Level 'SUCCESS'
return $server
}
else {
throw $_
}
}
}
catch {
Write-FailureLog -HostName $HostName -IPAddress $IPAddress -Reason $_.Exception.Message
return $null
}
}
function Get-ESXiHostInfo {
param(
[string]$HostName,
[object]$Server
)
try {
# Make sure Server is a single VMHost object
if ($Server -is [Array]) {
# If an array is returned, take the first item
$Server = $Server[0]
Write-Log -Message "Server returned as array, using first item" -Level 'WARNING'
}
Write-Log -Message "Getting host information for ${HostName}" -Level 'INFO'
# Get VMHost object
$vmhost = Get-VMHost -Name $HostName -Server $Server -ErrorAction Stop
Write-Log -Message "Retrieved host information for ${HostName}: Version $($vmhost.Version), Build $($vmhost.Build)" -Level 'INFO'
return $vmhost
}
catch {
Write-Log -Message "Failed to retrieve host information for ${HostName}: $_" -Level 'ERROR'
throw $_
}
}
function Get-ESXiImageProfile {
param (
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost]$VMHost
)
try {
$esxcli = Get-EsxCli -VMHost $VMHost -V2
$profileResult = $esxcli.software.profile.get.Invoke()
if ($profileResult) {
return $profileResult.Name
}
else {
Write-Log -Message "Unable to retrieve image profile for host $($VMHost.Name)" -Level 'WARNING'
return "Unknown"
}
}
catch {
Write-Log -Message "Failed to retrieve image profile for host $($VMHost.Name): $_" -Level 'WARNING'
return "Unknown"
}
}
function Get-ESXiInstallDate {
param (
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost]$VMHost
)
try {
$esxcli = Get-EsxCli -VMHost $VMHost -V2
$installDate = ($esxcli.software.vib.list.Invoke() | Where-Object { $_.Name -match "esx-base" }).InstallDate
if ($installDate) {
return $installDate
}
else {
Write-Log -Message "Unable to retrieve install date for host $($VMHost.Name)" -Level 'WARNING'
return "Unknown"
}
}
catch {
Write-Log -Message "Failed to retrieve install date for host $($VMHost.Name): $_" -Level 'WARNING'
return "Unknown"
}
}
function Get-ESXiSystemTime {
param (
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost]$VMHost
)
try {
$esxcli = Get-EsxCli -VMHost $VMHost -V2
$timeInfo = $esxcli.system.time.get.Invoke()
if ($timeInfo) {
return $timeInfo
}
else {
Write-Log -Message "Unable to retrieve system time for host $($VMHost.Name)" -Level 'WARNING'
return "Unknown"
}
}
catch {
Write-Log -Message "Failed to retrieve system time for host $($VMHost.Name): $_" -Level 'WARNING'
return "Unknown"
}
}
function Get-ESXiFilesystemInfo {
param (
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost]$VMHost
)
try {
$esxcli = Get-EsxCli -VMHost $VMHost -V2
$filesystemInfo = $esxcli.storage.filesystem.list.Invoke()
$volumeInfo = @()
foreach ($volume in $filesystemInfo) {
# Ensure size is a number (some versions of ESXi may return strings)
[double]$sizeBytes = if ($volume.Size -is [string]) { [double]::Parse($volume.Size) } else { $volume.Size }
[double]$freeBytes = if ($volume.Free -is [string]) { [double]::Parse($volume.Free) } else { $volume.Free }
$totalSizeGB = [math]::Round($sizeBytes / 1GB, 2)
$freeSpaceGB = [math]::Round($freeBytes / 1GB, 2)
$usedSpaceGB = [math]::Round($totalSizeGB - $freeSpaceGB, 2)
$percentFree = if ($totalSizeGB -gt 0) { [math]::Round(($freeSpaceGB / $totalSizeGB) * 100, 2) } else { 0 }
$volumeInfo += [PSCustomObject]@{
VolumeName = $volume.VolumeName
MountPoint = $volume.MountPoint
Type = $volume.Type
UUID = $volume.UUID
TotalSizeGB = $totalSizeGB
FreeSpaceGB = $freeSpaceGB
UsedSpaceGB = $usedSpaceGB
PercentFree = $percentFree
}
}
Write-Log -Message "Retrieved filesystem information for host $($VMHost.Name)" -Level 'INFO'
return $volumeInfo
}
catch {
Write-Log -Message "Failed to retrieve filesystem information for host $($VMHost.Name): $_" -Level 'ERROR'
return $null
}
}
function Get-ESXiHardwareInfo {
param (
[Parameter(Mandatory = $true)]
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost]$VMHost
)
try {
$view = Get-View $VMHost
$hardware = $view.Hardware
$assetTag = Get-ESXiAssetTag -VMHost $VMHost
$hardwareInfo = [PSCustomObject]@{
AssetTag = if ($assetTag) { $assetTag } else { "Unknown" }
SerialNumber = $hardware.SystemInfo.SerialNumber
BiosVersion = $hardware.BiosInfo.BiosVersion
BiosReleaseDate = $hardware.BiosInfo.ReleaseDate
Manufacturer = $hardware.SystemInfo.Vendor
Model = $hardware.SystemInfo.Model
LogicalProcessors = $hardware.CpuInfo.NumCpuThreads
ProcessorType = $VMHost.ProcessorType
Sockets = $hardware.CpuInfo.NumCpuPackages
CoresPerSocket = $hardware.CpuInfo.NumCpuCores
MemoryGB = [math]::Round($hardware.MemorySize / 1GB, 2)
}
Write-Log -Message "Retrieved hardware information for host $($VMHost.Name)" -Level 'INFO'
return $hardwareInfo
}
catch {
Write-Log -Message "Failed to retrieve hardware information for host $($VMHost.Name): $_" -Level 'ERROR'
return $null
}
}
function Get-ESXiAssetTag {
param (
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost]$VMHost
)
try {
$otherInfo = $VMHost.ExtensionData.Summary.Hardware.OtherIdentifyingInfo
$assetTag = $otherInfo | Where-Object { $_.IdentifierValue -match "^[A-Z0-9]{7,}" } | Select-Object -First 1
if ($assetTag) {
return $assetTag.IdentifierValue
}
else {
return "Unknown"
}
}
catch {
Write-Log -Message "Failed to retrieve asset tag for host $($VMHost.Name): $_" -Level 'WARNING'
return "Unknown"
}
}
function Get-ESXiNetworkInfo {
param (
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost]$VMHost
)
try {
$networkSystem = Get-View $VMHost.ExtensionData.ConfigManager.NetworkSystem
$dnsConfig = $networkSystem.DnsConfig
$ipRouteConfig = $networkSystem.IpRouteConfig
$vmkernelAdapters = Get-VMHostNetworkAdapter -VMHost $VMHost -VMKernel
$physicalAdapters = Get-VMHostNetworkAdapter -VMHost $VMHost -Physical
# Fix DNS server formatting
$dnsServers = @()
if ($dnsConfig.Address) {
$dnsServers = $dnsConfig.Address | ForEach-Object { $_.ToString() }
}
$networkInfo = [PSCustomObject]@{
Hostname = $VMHost.Name
IPAddresses = $vmkernelAdapters | ForEach-Object { "$($_.Name): $($_.IP)" }
DNSServers = $dnsServers
DefaultGateway = $ipRouteConfig.DefaultGateway
HostAdapters = $physicalAdapters.Count
IPv6Enabled = $VMHost.ExtensionData.Config.Network.Ipv6Enabled
}
Write-Log -Message "Retrieved network information for host $($VMHost.Name)" -Level 'INFO'
return $networkInfo
}
catch {
Write-Log -Message "Failed to retrieve network information for host $($VMHost.Name): $_" -Level 'ERROR'
return $null
}
}
function Get-ESXiReleaseInfo {
param (
[Parameter(Mandatory = $true)]
[string]$BuildNumber
)
$buildNumber = $BuildNumber.Trim()
# ESXi 8.0.x release mapping
$esxi8Releases = @{
"24674464" = @{ Version = "8.0.3"; ReleaseName = "ESXi 8.0 Update 3e (P05)"; ReleaseDate = "2025/04/10"; LatestStable = $true }
"24585383" = @{ Version = "8.0.3"; ReleaseName = "ESXi 8.0 Update 3d"; ReleaseDate = "2025/03/04"; LatestStable = $false }
"24585300" = @{ Version = "8.0.2"; ReleaseName = "ESXi 8.0 Update 2d"; ReleaseDate = "2025/03/04"; LatestStable = $false }
"24414501" = @{ Version = "8.0.3"; ReleaseName = "ESXi 8.0 Update 3c (EP3)"; ReleaseDate = "2024/12/12"; LatestStable = $false }
"24569005" = @{ Version = "8.0.0"; ReleaseName = "ESXi 8.0e"; ReleaseDate = "2025/03/11"; LatestStable = $false }
"24280767" = @{ Version = "8.0.3"; ReleaseName = "ESXi 8.0 Update 3b (P04)"; ReleaseDate = "2024/09/17"; LatestStable = $false }
"24022510" = @{ Version = "8.0.3"; ReleaseName = "ESXi 8.0 Update 3"; ReleaseDate = "2024/06/25"; LatestStable = $false }
"23825572" = @{ Version = "8.0.2"; ReleaseName = "ESXi 8.0 Update 2c (EP2)"; ReleaseDate = "2024/05/21"; LatestStable = $false }
"23299997" = @{ Version = "8.0.1"; ReleaseName = "ESXi 8.0 Update 1d"; ReleaseDate = "2024/03/05"; LatestStable = $false }
"23305546" = @{ Version = "8.0.2"; ReleaseName = "ESXi 8.0 Update 2b (P03)"; ReleaseDate = "2024/02/29"; LatestStable = $false }
"22380479" = @{ Version = "8.0.2"; ReleaseName = "ESXi 8.0 Update 2"; ReleaseDate = "2023/09/21"; LatestStable = $false }
"22088125" = @{ Version = "8.0.1"; ReleaseName = "ESXi 8.0 Update 1c (P02)"; ReleaseDate = "2023/07/27"; LatestStable = $false }
"21813344" = @{ Version = "8.0.1"; ReleaseName = "ESXi 8.0 Update 1a (EP1)"; ReleaseDate = "2023/06/01"; LatestStable = $false }
"21495797" = @{ Version = "8.0.1"; ReleaseName = "ESXi 8.0 Update 1"; ReleaseDate = "2023/04/18"; LatestStable = $false }
"21493926" = @{ Version = "8.0.0"; ReleaseName = "ESXi 8.0c (EP2)"; ReleaseDate = "2023/03/30"; LatestStable = $false }
"21203435" = @{ Version = "8.0.0"; ReleaseName = "ESXi 8.0b (P01)"; ReleaseDate = "2023/02/14"; LatestStable = $false }
"20842819" = @{ Version = "8.0.0"; ReleaseName = "ESXi 8.0a (EP1)"; ReleaseDate = "2022/12/08"; LatestStable = $false }
"20513097" = @{ Version = "8.0.0"; ReleaseName = "ESXi 8.0 GA"; ReleaseDate = "2022/10/11"; LatestStable = $false }
}
# ESXi 7.0.x release mapping
$esxi7Releases = @{
"24585291" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3s"; ReleaseDate = "2025/03/04"; LatestStable = $true }
"24411414" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3r (EP12)"; ReleaseDate = "2024/12/12"; LatestStable = $false }
"23794027" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3q (P09)"; ReleaseDate = "2024/05/21"; LatestStable = $false }
"23307199" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3p (EP11)"; ReleaseDate = "2024/04/11"; LatestStable = $false }
"22348816" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3o (P08)"; ReleaseDate = "2023/09/28"; LatestStable = $false }
"21930508" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3n (EP10)"; ReleaseDate = "2023/07/07"; LatestStable = $false }
"21686933" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3m (EP9)"; ReleaseDate = "2023/05/03"; LatestStable = $false }
"21424296" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3l (P07)"; ReleaseDate = "2023/03/30"; LatestStable = $false }
"21313628" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3k (EP8)"; ReleaseDate = "2023/02/21"; LatestStable = $false }
"21053776" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3j (EP7)"; ReleaseDate = "2023/01/31"; LatestStable = $false }
"20842708" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3i (P06)"; ReleaseDate = "2022/12/08"; LatestStable = $false }
"20328353" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3g (EP5)"; ReleaseDate = "2022/09/01"; LatestStable = $false }
"20036589" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3f (P05)"; ReleaseDate = "2022/07/12"; LatestStable = $false }
"19898904" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3e (EP4)"; ReleaseDate = "2022/06/14"; LatestStable = $false }
"19482537" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3d (P04)"; ReleaseDate = "2022/03/29"; LatestStable = $false }
"19290878" = @{ Version = "7.0.2"; ReleaseName = "ESXi 7.0 Update 2e (EP3)"; ReleaseDate = "2022/02/15"; LatestStable = $false }
"19324898" = @{ Version = "7.0.1"; ReleaseName = "ESXi 7.0 Update 1e (EP4)"; ReleaseDate = "2022/02/15"; LatestStable = $false }
"19193900" = @{ Version = "7.0.3"; ReleaseName = "ESXi 7.0 Update 3c"; ReleaseDate = "2022/01/27"; LatestStable = $false }
"18538813" = @{ Version = "7.0.2"; ReleaseName = "ESXi 7.0 Update 2d (EP2)"; ReleaseDate = "2021/09/14"; LatestStable = $false }
"18426014" = @{ Version = "7.0.2"; ReleaseName = "ESXi 7.0 Update 2c (P03)"; ReleaseDate = "2021/08/24"; LatestStable = $false }
"17867351" = @{ Version = "7.0.2"; ReleaseName = "ESXi 7.0 Update 2a (EP1)"; ReleaseDate = "2021/04/29"; LatestStable = $false }
"17630552" = @{ Version = "7.0.2"; ReleaseName = "ESXi 7.0 Update 2"; ReleaseDate = "2021/03/09"; LatestStable = $false }
"17551050" = @{ Version = "7.0.1"; ReleaseName = "ESXi 7.0 Update 1d (EP3)"; ReleaseDate = "2021/02/02"; LatestStable = $false }
"17325551" = @{ Version = "7.0.1"; ReleaseName = "ESXi 7.0 Update 1c (P02)"; ReleaseDate = "2020/12/17"; LatestStable = $false }
"17168206" = @{ Version = "7.0.1"; ReleaseName = "ESXi 7.0 Update 1b (EP2)"; ReleaseDate = "2020/11/19"; LatestStable = $false }
"17119627" = @{ Version = "7.0.1"; ReleaseName = "ESXi 7.0 Update 1a (EP1)"; ReleaseDate = "2020/11/04"; LatestStable = $false }
"16850804" = @{ Version = "7.0.1"; ReleaseName = "ESXi 7.0 Update 1"; ReleaseDate = "2020/10/06"; LatestStable = $false }
"16324942" = @{ Version = "7.0.0"; ReleaseName = "ESXi 7.0b (P01)"; ReleaseDate = "2020/06/23"; LatestStable = $false }
"15843807" = @{ Version = "7.0.0"; ReleaseName = "ESXi 7.0 GA"; ReleaseDate = "2020/04/02"; LatestStable = $false }
}
# Check in ESXi 8.0 releases
if ($esxi8Releases.ContainsKey($buildNumber)) {
return $esxi8Releases[$buildNumber]
}
# Check in ESXi 7.0 releases
if ($esxi7Releases.ContainsKey($buildNumber)) {
return $esxi7Releases[$buildNumber]
}
# Unknown build number
return @{
Version = "Unknown";
ReleaseName = "Unknown Release";
ReleaseDate = "Unknown";
LatestStable = $false
}
}
function Test-CPUCompatibility {
param (
[string]$ProcessorType,
[string]$Manufacturer,
[string]$Model
)
# Define CPU families and specific models that are supported for ESXi 8.x
$supportedCPUs = @{
# Intel Xeon Scalable (Ice Lake and later)
'Platinum' = @('8[0-9]{3}[A-Z]?') # 8xxx series
'Gold' = @('6[0-9]{3}[A-Z]?', '5[0-9]{3}[A-Z]?') # 6xxx and 5xxx series
'Silver' = @('4[0-9]{3}[A-Z]?') # 4xxx series
'Bronze' = @('3[0-9]{3}[A-Z]?') # 3xxx series
# Intel 2nd/3rd Gen Xeon Scalable CPUs (explicitly supported)
'Cascadelake' = @(
'Gold 6248', 'Gold 6246', 'Gold 6242', 'Gold 6240', 'Gold 6238',
'Gold 6230', 'Gold 6226', 'Gold 6208U', 'Gold 5220', 'Gold 5218',
'Gold 5217', 'Gold 5215', 'Silver 4215', 'Silver 4214', 'Silver 4210'
)
# 3rd Gen Xeon Scalable (Ice Lake)
'IceLake' = @(
'Gold 6338', 'Gold 6330', 'Gold 6326', 'Gold 5318', 'Gold 5315',
'Silver 4316', 'Silver 4314', 'Silver 4310'
)
# Specific known-good models
'Specific' = @(
# Recent Xeon models (known compatible)
'Gold 6150', 'Gold 6132', 'Gold 6126',
'Silver 4114', 'Silver 4110'
)
# AMD EPYC 7xx2 (Rome) and 7xx3 (Milan) series
'EPYC' = @(
'7742', '7702', '7662', '7642', '7552',
'7542', '7532', '7502', '7452', '7402',
'7352', '7302', '7282', '7272', '7262',
'7252', '7232',
'7763', '7713', '7663', '7643', '7573',
'7543', '7513', '7453', '7443', '7413',
'7343', '7313'
)
# Explicitly unsupported models
'Unsupported' = @(
'E5-2680 v3', 'E5-2660 v3', 'E5-2650 v3', 'E5-2640 v3', 'E5-2630 v3',
'E5-2620 v3', 'E5-2609 v3', 'E5-2603 v3', 'E5-2697 v2', 'E5-2695 v2',
'E5-2690 v2', 'E5-2680 v2', 'E5-2670 v2', 'E5-2660 v2', 'E5-2650 v2',
'E5-2640 v2', 'E5-2630 v2', 'E5-2620 v2', 'E5-2609 v2', 'E5-2603 v2',
'E5-2697 v1', 'E5-2695 v1', 'E5-2690 v1', 'E5-2680 v1', 'E5-2670 v1'
)
}
# Create a result object with detailed information
$result = [PSCustomObject]@{
IsCompatible = $false
Reason = ""
CPUModel = $ProcessorType
CompatibilityNotes = ""
Icon = "X" # Using ASCII characters instead of Unicode
}
# First check explicitly unsupported models
foreach ($unsupportedCPU in $supportedCPUs['Unsupported']) {
if ($ProcessorType -match [regex]::Escape($unsupportedCPU)) {
$result.Reason = "CPU model $ProcessorType is explicitly unsupported for ESXi 8.x"
$result.CompatibilityNotes = "This CPU generation is too old for ESXi 8.x"
$result.Icon = "X"
Write-Log -Message $result.Reason -Level 'WARNING'
return $result
}
}
# Check specific supported models
foreach ($cpuCategory in @('Specific', 'Cascadelake', 'IceLake')) {
foreach ($specificCPU in $supportedCPUs[$cpuCategory]) {
if ($ProcessorType -match [regex]::Escape($specificCPU)) {
$result.IsCompatible = $true
$result.Reason = "CPU model $ProcessorType is explicitly supported for ESXi 8.x"
$result.CompatibilityNotes = "This CPU model is explicitly verified as compatible"
$result.Icon = "√"
Write-Log -Message $result.Reason -Level 'SUCCESS'
return $result
}
}
}
# Check Intel Scalable family processors (Cascade Lake and newer)
foreach ($family in @('Platinum', 'Gold', 'Silver', 'Bronze')) {
foreach ($pattern in $supportedCPUs[$family]) {
if ($ProcessorType -match "Intel.*Xeon.*$family.*$pattern") {
$result.IsCompatible = $true
$result.Reason = "CPU model $ProcessorType is supported for ESXi 8.x (Scalable family)"
$result.CompatibilityNotes = "This Intel Xeon Scalable CPU is compatible"
$result.Icon = "√"
Write-Log -Message $result.Reason -Level 'SUCCESS'
return $result
}
}
}
# Check AMD EPYC processors
if ($ProcessorType -match "AMD.*EPYC") {
foreach ($model in $supportedCPUs['EPYC']) {
if ($ProcessorType -match $model) {
$result.IsCompatible = $true
$result.Reason = "CPU model $ProcessorType is supported for ESXi 8.x (AMD EPYC)"
$result.CompatibilityNotes = "This AMD EPYC CPU is compatible"
$result.Icon = "√"
Write-Log -Message $result.Reason -Level 'SUCCESS'
return $result
}
}
}
# If we're still here, check generation for Intel CPUs
if ($ProcessorType -match "Intel.*Xeon.*E5") {
# Check for v4 or higher which are generally compatible
if ($ProcessorType -match "v[4-9]") {
$result.IsCompatible = $true
$result.Reason = "CPU model $ProcessorType is likely supported for ESXi 8.x (Broadwell or newer)"
$result.CompatibilityNotes = "E5 v4 or newer CPUs are generally compatible"
$result.Icon = "√"
Write-Log -Message $result.Reason -Level 'SUCCESS'
return $result
}
}
# If no match found, consider potentially compatible but warn
$result.IsCompatible = $false
$result.Reason = "CPU model $ProcessorType is not verified as supported for ESXi 8.x"
$result.CompatibilityNotes = "Could not verify compatibility - manual check recommended"
$result.Icon = "?"
Write-Log -Message $result.Reason -Level 'WARNING'
return $result
}
function Test-StorageReadiness {
param (
[array]$VolumeInfo,
[double]$MinimumRequiredSpaceGB,
[double]$MinimumBootbankFreePercentage
)
$osdataPartition = $VolumeInfo | Where-Object { $_.VolumeName -like "OSDATA*" }
$bootbank1Partition = $VolumeInfo | Where-Object { $_.VolumeName -eq "BOOTBANK1" }
$bootbank2Partition = $VolumeInfo | Where-Object { $_.VolumeName -eq "BOOTBANK2" }
# Initialize result object with detailed information
$result = [PSCustomObject]@{
IsReady = $true
Issues = @()
OSDATASize = if ($osdataPartition) { $osdataPartition.TotalSizeGB } else { 0 }
OSDATAFree = if ($osdataPartition) { $osdataPartition.FreeSpaceGB } else { 0 }
BOOTBANK1Size = if ($bootbank1Partition) { $bootbank1Partition.TotalSizeGB } else { 0 }
BOOTBANK1Free = if ($bootbank1Partition) { $bootbank1Partition.FreeSpaceGB } else { 0 }
BOOTBANK2Size = if ($bootbank2Partition) { $bootbank2Partition.TotalSizeGB } else { 0 }
BOOTBANK2Free = if ($bootbank2Partition) { $bootbank2Partition.FreeSpaceGB } else { 0 }
}
# Check OSDATA partition
if ($osdataPartition) {
if ($osdataPartition.FreeSpaceGB -lt $MinimumRequiredSpaceGB) {
$result.IsReady = $false
$issue = "OSDATA has insufficient free space: $($osdataPartition.FreeSpaceGB) GB (Required: $MinimumRequiredSpaceGB GB)"
$result.Issues += $issue
Write-Log -Message $issue -Level 'WARNING'
}
}
else {
# For older ESXi versions that might not have OSDATA
$result.Issues += "No OSDATA partition found - this may indicate an older ESXi version"
Write-Log -Message "No OSDATA partition found - this may indicate an older ESXi version" -Level 'WARNING'
}
# Function to check bootbank partitions
function Test-BootbankPartition {
param (
$Partition,
[string]$PartitionName,
[double]$RequiredFreePercentage
)
if (-not $Partition) {
$result.IsReady = $false
$issue = "$PartitionName partition not found"
$result.Issues += $issue
Write-Log -Message $issue -Level 'WARNING'
return
}
if ($Partition.TotalSizeGB -lt 4) {
$result.IsReady = $false
$issue = "$PartitionName is undersized (< 4 GB): $($Partition.TotalSizeGB) GB"
$result.Issues += $issue
Write-Log -Message $issue -Level 'WARNING'
}
$freePercentage = ($Partition.FreeSpaceGB / $Partition.TotalSizeGB) * 100
if ($freePercentage -lt $RequiredFreePercentage) {
$result.IsReady = $false
$issue = "$PartitionName has insufficient free space: $($Partition.FreeSpaceGB) GB ($($freePercentage.ToString('F2'))% free, required: $RequiredFreePercentage%)"
$result.Issues += $issue
Write-Log -Message $issue -Level 'WARNING'
}
}
# Check bootbank partitions
Test-BootbankPartition -Partition $bootbank1Partition -PartitionName "BOOTBANK1" -RequiredFreePercentage $MinimumBootbankFreePercentage
Test-BootbankPartition -Partition $bootbank2Partition -PartitionName "BOOTBANK2" -RequiredFreePercentage $MinimumBootbankFreePercentage
# Additional storage sanity checks (to prevent false negatives)
$allVolumes = $VolumeInfo | Where-Object { $_.VolumeName -notlike "OSDATA*" -and $_.VolumeName -ne "BOOTBANK1" -and $_.VolumeName -ne "BOOTBANK2" }
$totalFreeSpace = ($allVolumes | Measure-Object -Property FreeSpaceGB -Sum).Sum
# If we have significant free space elsewhere but issues with specific partitions,
# add a note about possible partition resizing
if ($result.IsReady -eq $false -and $totalFreeSpace -gt $MinimumRequiredSpaceGB * 2) {
$result.Issues += "NOTE: System has $totalFreeSpace GB free space on other partitions - partition resizing might resolve space issues"
}
if ($result.IsReady) {
Write-Log -Message "Storage check passed - sufficient space available for upgrade" -Level 'SUCCESS'
}
else {
Write-Log -Message "Storage check failed - issues found: $($result.Issues -join '; ')" -Level 'WARNING'
}
return $result
}
function Test-DirectUpgradePathAvailable {
param (
[string]$CurrentVersion,
[string]$TargetVersion
)
$result = [PSCustomObject]@{
IsDirectUpgradePossible = $false
RequiredIntermediateVersion = $null
Reason = ""
}
# Convert versions to Version objects for comparison
$currentVer = [version]($CurrentVersion -replace '^([0-9]+\.[0-9]+).*', '$1')
$targetVer = [version]($TargetVersion -replace '^([0-9]+\.[0-9]+).*', '$1')
# Check for direct upgrade path
# ESXi 6.7 or 7.0 can upgrade directly to 8.0
if ($currentVer -ge [version]"6.7") {
$result.IsDirectUpgradePossible = $true
$result.Reason = "Direct upgrade path available from ESXi $CurrentVersion to $TargetVersion"
Write-Log -Message $result.Reason -Level 'SUCCESS'
}
elseif ($currentVer -ge [version]"6.5") {
$result.IsDirectUpgradePossible = $false
$result.RequiredIntermediateVersion = "6.7"
$result.Reason = "Must upgrade to ESXi 6.7 first, then to $TargetVersion"
Write-Log -Message $result.Reason -Level 'WARNING'