-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcluchkdev.ps1
6349 lines (5847 loc) · 358 KB
/
cluchkdev.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
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
S2D Ready Node Deployment Checker
.DESCRIPTION
Script to verify the Dell S2D Ready Node Deployment guide was implemented fully
.CREATEDBY
Jim Gandy
and others
.NOTES
The script can be called without any parameters
examples:
.\CluChk.ps1
.\CluChk.ps1 -runType 3 -uploadToAzure $false -SDDCInputFolder 'C:\customer logs\Customer X - HCI\HealthTest-OL-P-HCI-CL01-20230308-1618\'
.Parameter runType
Specifies what to process, values are the same as menu values
.Parameter SDDCInputFolder
Location of the extracted SDDC collection
.Parameter TSRInputFolder
Locaton of the TSR/Support Assist files
.Parameter STSInputFolder
Location of the Show Tech support files
.Parameter uploadToAzure
Specifies if the collected data should be uploaded in Azure for analysis
.Parameter debug
Specifies to show debug information
.UPDATES
2024/04/09:v1.56 - 1. Bug Fix:JG - Added -UseBasicParsing to all Invoke-WebRequests for Server OS compatability
2024/04/09:v1.55 - 1. New Feature:TP - Drift moved to GitHub
2024/04/05:v1.54 - 1. Bug Fix:TP - Fixed Computer Nodes section missing due to previous fix.
2024/04/03:v1.53 - 1. Bug Fix:TP - If IOV is enabled ignore the BandwidthReservationMode and BandwidthPercentage settings
2. New Feature:TP - On LRs request, check for Mixed Mode clusters and show a problem in the Cluster Name object
3. Bug Fix: Using GetComputerInfo.xml instead of SystemInfo.txt because it seems to gather more reliabily
4. New Feature: JG - Added Invoke-RunCluChk
2024/03/13:v1.52 - 1. New Feature: TP - Change HTML Agility pack to only download if not in C:\ProgramData\Dell\htmlagilitypack
2. New Feature: JG - Added APEX version to OSVersionNodes so that 23H2 will be red for non-APEX until we support it
3. New Feature: JG/TP - Cluster Heartbeat Configuration - Added check for Stretch Cluster heartbeat settings
4. Bug Fix: TP - Fixed an issue with System Page file that I caused in 1.51
5. Bug Fix: TP - Net Qos Dcbx Property table was not flagging Firmware in Charge as an Error
6. New Feature: TP - Added the file system to Cluster Shared Volumes
7. Bug Fix: TP - Net QOS Traffic Class was calling out ETS as an error when it is configured correctly.
8. New Feature: TP - Wrote PS Function to pull HTML tables. Removed downloading HTMLAgilityPack and changed sections using it.
2024/02/09:v1.51 - 1. New Feature: TP - Call out a warning for a Cluster network with an IP but the Cluster Role set to None
2. New Feature: JG - Jumbo Frames: Changes Slot to Port and added Intel Nics for APEX support
3. New Feature: JG - Net Adapter Qos: ONLY check if Quality Of Service for APEX support
4. Bug Fix: TP - Qos DBCX settings did not show the Node name
5. New Feature: JG - Cluster Name: Added 23H2 for APEX support
6. New Feature: JG - Cluster Nodes: Added 25398 to OSBuild for APEX support
7. Bug Fix: JG - Net Qos Dcbx Property: Do not show if no dhbxmode found
2024/01/25:v1.50 - 1. New Feature: JG - Cluster Nodes - Added check for EoL Operation Systems
2. Bug Fix: TP - Fixed disk firmware showing older firmware preferred if two are in the support matrix
3. Bug Fix: TP - Fixed Storage Network Cards and Node map due to changing to using jobs for all commands
4. Bug Fix: TP - Net QOS traffic class not showing correctly
5. New Feature: TP - Added unknown Net QOS Traffic Classes to the table
6. Bug Fix: TP - Change OEM Support Provider to only call out if it does not contain 'dell'
See previous version for update notes
#>
Function Invoke-RunCluChk{
param (
[int]$runType = 0,
[string]$SDDCInputFolder = '',
[string]$TSRInputFolder = '',
[string]$STSInputFolder = '',
[boolean]$uploadToAzure = $false,
[boolean]$debug = $false
)
$CluChkVer="1.56DEV"
#Fix "The response content cannot be parsed because the Internet Explorer engine is not available"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Value 2
#region Variable Cleanup
#The following line causes alot of errors and does not appear to accomplish what is required.
# Remove-Variable * -Scope Local -ErrorAction SilentlyContinue
# Recommend using a prefix on variables so remove-variable can -include prefix*
$TLogLoc = "C:\programdata\Dell\CluChk"
$DateTime=Get-Date -Format yyyyMMdd_HHmmss;Start-Transcript -NoClobber -Path "$TlogLoc\CluChk_$DateTime.log"
[system.gc]::Collect()
#endregion
# Function to convert HTML table to PowerShell object
function Convert-HtmlTableToPsObject {
param (
[string]$HtmlContent
)
# Define regular expressions to match table names, tables, rows, and cells
$tableRegex = '(?s)<h3 id="([^"]+)">(.*?)</h3>.*?<table[^>]*>(.*?)</table>'
$tableNoNameRegex = '(?s)<table[^>]*>(.*?)</table>'
$rowRegex = '<t[^>]*>(.*?)</?tr>'
$thCellRegex = '<th[^>]*>(.*?)</th>'
$tdCellRegex = '(.*?)</td>'
$rowSpanRegex = 'rowspan="(\d+)"'
# Find tables in HTML content
$NoName=$false
$tableMatches = [regex]::Matches($HtmlContent, $tableRegex)
If ($tableMatches.count -eq 0) {
$tableMatches = [regex]::Matches($HtmlContent, $tableNoNameRegex)
$NoName=$true
}
$result = @{}
$tableNo=0
foreach ($tableMatch in $tableMatches) {
If ($NoName) {
$tableName=$tableNo
$tableNo++
$tableHtml = $tableMatch.Groups[1].Value
} else {
$tableName = $tableMatch.Groups[2].Value
$tableHtml = $tableMatch.Groups[3].Value
}
#Write-Host "Table Name is $tableName"
# Get column headers from <th> cells
$headers = @()
[regex]::Matches($tableHtml, $thCellRegex) | ForEach-Object {
$headers += $_.Groups[1].Value
}
#Write-Host "Headers count is $($headers.count)"
# Find maximum rowspan value in the table (which is the number of rows)
$maxRowSpan = [regex]::Matches($tableHtml, $rowRegex).Count
#Write-Host "Number of rows are $maxRowSpan"
# Initialize the array to store rows
$rows = @()
for ($i = 0; $i -le $maxRowSpan; $i++) {
$rows += @{}
}
# Find table rows
$rowMatches = [regex]::Matches($tableHtml, $rowRegex)
$rowIndex = 0
foreach ($rowMatch in ($rowMatches | Select-Object -Skip 1)) {
#$rowData = [PSCustomObject]@{}
#$rowData = $rowData | Select-Object -Property $headers
$rowData = @{}
$rowHtml= $null
$rowHtml = $rowMatch.Groups[1].Value
$cellMatches = [regex]::Matches($rowHtml, $tdCellRegex)
If ($cellMatches.count -eq 0) {Write-Host "Rowhtml is $rowHtml"}
$colIndex = 0
foreach ($cellMatch in $cellMatches) {
$curHeader=$headers[$colIndex]
$cell = $cellMatch.Groups[1].Value -replace "<td[^>]*>",""
$rowSpanMatch = [regex]::Match(($rowHtml -split '</td>')[$colIndex], $rowSpanRegex)
$rowSpan = 1
if ($rowSpanMatch.Success) {
$rowSpan = [int]$rowSpanMatch.Groups[1].Value
}
if ($rowSpan -gt 1) {
$rowData.$curHeader = $cell
for ($j = 1; $j -lt $rowSpan-1; $j++) {
if ($rows[$rowIndex + $j] -eq $Null) {
$rows[$rowIndex + $j] = [PSCustomObject]@{}
$rows[$rowIndex + $j] = $rows[$rowIndex + $j] | Select-Object -Property $headers
}
$rows[$rowIndex + $j].$curHeader = $cell
}
} else {
$existingData = $null
try {$existingData = $rows[$rowIndex].$curHeader} catch {$existingData = $null}
if ($existingData -ne $null) {
$rowData.$curHeader = $existingData
} else {
try {$rowData.$curHeader = $cell} catch {}
}
}
$colIndex++
}
# Update row data in the array
#if ($colIndex -lt $headers.count-1) {throw 'ready to test copy'}
$rows[$rowIndex] = $rows[$rowindex]+$rowdata
$rowIndex++
}
# Add the rows for this table to the hashtable
$result[$tableName] = $rows
}
# Output the hashtable
return $result
}
#region Cleanup CluChk Transcripts older than 10 days
function TLogCleanup {
Get-ChildItem $TlogLoc | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-10)} | Foreach {Remove-Item $_.Fullname}
# Cleanup chipset extract
Remove-Variable IntelChipset* -Scope Local -ErrorAction SilentlyContinue
IF($IntelChipsetDownloadLocation){Remove-Item $IntelChipsetDownloadLocation}
IF($IntelChipsetDupExtractLocation){Remove-Item $IntelChipsetDupExtractLocation -Recurse}
}
#endregion
# Create a unique Guid to use for file names
$CluChkGuid=(New-Guid).GUID
#endregion
<#
#Async download of Agility pack
Start-Job -Name "AgilityPack" -ScriptBlock {
# Download htmlagilitypack
If (!(Get-ChildItem -Path "C:\ProgramData\Dell\htmlagilitypack" -ErrorAction SilentlyContinue -Recurse -Filter 'Net45' | Get-ChildItem | Where-Object{$_.Name -imatch 'HtmlAgilityPack.dll'}).count) {
try {
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/HtmlAgilityPack\1.11.46" -OutFile "$env:TEMP\htmlagilitypack.nupkg.zip" -TimeoutSec 30
}
catch {
Throw ('Unable to download HTMLAgilityPack')
}
finally {
# Find the htmlagilitypack.dll
Expand-Archive "$env:TEMP\htmlagilitypack.nupkg.zip" -DestinationPath "C:\ProgramData\Dell\htmlagilitypack" -force -ErrorAction SilentlyContinue
}
}}
#>
Function EndScript{
For ($i=0; $i -le 100; $i++) {
Start-Sleep -Milliseconds 5
Write-Progress -Activity "Exit Timer" -Status " " -PercentComplete $i
}
break script
}
$WhatsNew=@"
1. in dev
"@
#region Opening Banner and menu
if (!$runType) {Clear-Host}
$text = @"
v$CluChkVer
_____ _ _____ _ _
/ ____| | ___ / ____| | | |
| | | |_ _| | | |__ | | __
| | | | | | | | | '_ \| |/ /
| |____| | |_| | |____| | | | <
\_____|_|\__,_|\_____|_| |_|_|\_\
by: Jim Gandy
"@
$Oops=@"
Oops... Something went wrong. Please try again.
"@
Write-Host $text
Write-Host ""
# Run Menu
Function ShowMenu{
do
{
$Global:selection=""
Clear-Host
Write-Host $text
Write-Host ""
Write-Host "============ Please make a selection ==================="
Write-Host ""
Write-Host "Press '1' to Process Show Tech-Support(s)"
Write-Host "Press '2' to Process Support Assist Collection(s)"
Write-Host "Press '3' to Process PrivateCloud.DiagnosticInfo (SDDC)"
Write-Host "Press '4' to Process S2D\HCI Performance Report"
Write-Host "Press '5' to Process All the above"
Write-Host "Press 'H' to Display Help"
Write-Host "Press 'Q' to Quit"
Write-Host ""
$Global:selection = Read-Host "Please make a selection"
}
until ($Global:selection -match '[1-5,qQ,hH]')
$Global:ProcessSTS = "N"
$Global:ProcessSDDC = "N"
$Global:ProcessTSR = "N"
$Global:ProcessPerformanceReport = "N"
IF($selection -imatch 'h'){
Clear-Host
Write-Host ""
Write-Host "What's New in"$CluChkVer":"
Write-Host $WhatsNew
Write-Host ""
Write-Host "Usage:"
Write-Host " Make a selection by entering a comma delimited string of numbers from the menu."
Write-Host ""
Write-Host " Example: 1 will process Show Tech-Support(s) only and create a report."
Write-Host " Show Tech-Support is a log collection from a Dell switch."
Write-Host ""
Write-Host " Example: 1,3 will process Show Tech-Support(s) and "
Write-Host " PrivateCloud.DiagnosticInfo (SDDC) and create a report."
Write-Host ""
Pause
ShowMenu
}
IF($Global:selection -match 1){
Write-Host "Process Show Tech-Support(s)..."
$Global:ProcessSTS = "Y"
}
IF($Global:selection -match 2){
Write-Host "Process Support Assist Collection(s)..."
$Global:ProcessTSR = "Y"
}
IF($Global:selection -match 3){
Write-Host "Process PrivateCloud.DiagnosticInfo (SDDC)..."
$Global:ProcessSDDC = "Y"
}
IF($Global:selection -match 4){
Write-Host "Process SDDC Performance Report..."
$Global:ProcessPerformanceReport = "Y"
#Enabled to get the SDDC then disabled once we have it
$Global:ProcessSDDC = "Y"
}
ElseIF($Global:selection -eq 5){
Write-Host "Process Show Tech-Support(s) + Support Assist Collection(s) + PrivateCloud.DiagnosticInfo (SDDC) + SDDC Performance Report..."
$Global:ProcessSTS = "Y"
$Global:ProcessSDDC = "Y"
$Global:ProcessTSR = "Y"
$Global:ProcessPerformanceReport = "Y"
}
IF($Global:selection -imatch 'q'){
Write-Host "Bye Bye..."
EndScript
}
}#End of ShowMenu
#endregion
if ($runType -eq 0) {
ShowMenu
} else {
$Global:ProcessSTS = "N"
$Global:ProcessSDDC = "N"
$Global:ProcessTSR = "N"
$Global:ProcessPerformanceReport = "N"
switch ($runType) {
1 {$Global:ProcessSTS = "Y"}
2 {$Global:ProcessTSR = "Y"}
3 {$Global:ProcessSDDC = "Y"}
4 {
$Global:ProcessPerformanceReport = "Y"
$Global:ProcessSDDC = "Y"
}
5 {
$Global:ProcessSTS = "Y"
$Global:ProcessSDDC = "Y"
$Global:ProcessTSR = "Y"
}
}
}
Set-Variable -Name htmlout -Scope Global
#region Telemetry Information
Write-Host "Logging Telemetry Information..."
function add-TableData {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $tableName,
[Parameter(Mandatory = $true)]
[string] $PartitionKey,
[Parameter(Mandatory = $true)]
[string] $RowKey,
[Parameter(Mandatory = $true)]
[array] $data,
[Parameter(Mandatory = $false)]
[array] $SasToken
)
if ($uploadToAzure) {
$storageAccount = "gsetools"
# Allow only add and update access via the "Update" Access Policy on the CluChkTelemetryData table
# Ref: az storage table generate-sas --connection-string 'USE YOUR KEY' -n "CluChkTelemetryData" --policy-name "Update"
If(-not($SasToken)){
$sasWriteToken = "?sv=2017-04-17&si=Update&tn=CluChkTelemetryData&sig=NP2ZQnHuUhOAOyGhzd94GVbKrBqhYlIKjX%2BVrhAjFoE%3D"
}Else{$sasWriteToken=$SasToken}
$resource = "$tableName(PartitionKey='$PartitionKey',RowKey='$Rowkey')"
# should use $resource, not $tableNmae
$tableUri = "https://$storageAccount.table.core.windows.net/$resource$sasWriteToken"
# Write-Host $tableUri
# should be headers, because you use headers in Invoke-RestMethod
$headers = @{
Accept = 'application/json;odata=nometadata'
}
$body = $data | ConvertTo-Json
#This will write to the table
#write-host "Invoke-RestMethod -Method PUT -Uri $tableUri -Headers $headers -Body $body -ContentType application/json"
try {
$item = Invoke-RestMethod -Method PUT -Uri $tableUri -Headers $headers -Body $body -ContentType application/json
} catch {
#write-warning ("table $tableUri")
#write-warning ("headers $headers")
}
} # if upload
}# End function add-TableData
# Generating a unique report id to link telemetry data to report data
$CReportID=""
$CReportID=(new-guid).guid
# Get the internet connection IP address by querying a public API
#$internetIp = (Invoke-WebRequest -uri "http://ifconfig.me/ip" -UseBasicParsing).Content
# Define the API endpoint URL
$geourl = "http://ip-api.com/json" #$geourl = "http://ip-api.com/json/$internetIp"
# Invoke the API to determine Geolocation
$response = Invoke-RestMethod $geourl
$data = @{
Region=$env:UserDomain
Version=$CluChkVer
ReportID=$CReportID
country=$response.country
counrtyCode=$response.countryCode
georegion=$response.region
regionName=$response.regionName
city=$response.city
zip=$response.zip
lat=$response.lat
lon=$response.lon
timezone=$response.timezone
}
$RowKey=(new-guid).guid
$PartitionKey="CluChk"
#Make sure we get telemetry if uploadToAzure = $False
If($uploadToAzure -eq $false){
$uploadToAzure = $true
add-TableData -TableName "CluChkTelemetryData" -PartitionKey $PartitionKey -RowKey $RowKey -data $data
$uploadToAzure=$false
}Else{add-TableData -TableName "CluChkTelemetryData" -PartitionKey $PartitionKey -RowKey $RowKey -data $data}
#endregion End of Telemetry data
# unzip files
function Unzip {
param([string]$zipfile, [string]$outpath)
Write-Host " Expanding: "
Write-Host " $SDDCLoc "
Write-Host " To:"
Write-Host " $ExtracLoc"
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
Function Get-FileName([string]$initialDirectory, [string]$infoTxt, [string]$filter) {
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog -Property @{MultiSelect = $true}
$OpenFileDialog.Title = $infoTxt
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = $filter
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filenames
}
#region Ask for Show Tech-Support files
#$ProcessSTS = Read-Host "Would you like to process Show Tech-Supports? [y/n]"
IF($ProcessSTS -ieq "y"){
if ($STSInputFolder -eq '') {
Write-Host "Please Select Show Tech-Support File(s) to use..."
$STSLOC = Get-FileName "$env:USERPROFILE\Documents\SRs" "Please Select Show Tech-Support File(s)." "Logs (*.zip,*.txt,*.log)| *.zip;*.TXT;*.log"
} else {
$STSLOC = $STSInputFolder
}
If ($STSLOC.length -eq 0) {
Write-Host " ERROR: Empty path given. Existing" -ForegroundColor Red
EndScript
}
if (!(Test-Path -Path $STSLOC)) {
Write-Host " ERROR: STS Path does not exist. Existing" -ForegroundColor Red
EndScript
}
# unzip files
$STSFiles=@()
$CluChkReportLoc=(Split-Path -Path $STSLOC)
$STSExtracLoc=(Split-Path -Path $STSLOC)+"\"+ (Split-Path -Path $STSLOC -Leaf).Split(".")[0]
ForEach($STSFile in $STSLOC){
If($STSFile -imatch '.zip'){
unzip $STSFile $STSExtracLoc
$STSFiles+=(Get-ChildItem $STSExtracLoc).fullName
}Else{$STSFiles+=$STSFile}
}
} # if $ProcessSTS
#endregion
#region $ProcessSDDC = Read-Host "Would you like to process SDDC? [y/n]"
IF($ProcessSDDC -ieq "y"){
Write-Host "Starting SDDC..."
IF($ProcessPerformanceReport -ieq "y"){
$SDDCPerf="YES"
}Else{$SDDCPerf="NO"}
if ($SDDCInputFolder -eq '') {
# no input folder given
# Added to Select-Object the extracted SDDC
$SDDCExtracted = Read-Host " Do you already have an extracted SDDC? [y/n]"
IF($SDDCExtracted -ieq "y") {
$SDDCExtracted="YES"
Write-Host " Please Provide the path to the extracted SDDC. "
Write-Host " Do NOT include Quotes even if path includes spaces."
Write-Host " Ex: c:\SRs\81449725\HealthTest-NL70U00CL02-20200928-1130"
$SDDCPath=Read-Host " Path"
$IR=1
$CluChkReportLoc=Split-Path -Path $SDDCPath
$ExtracLoc=(Split-Path -Path $SDDCPath) +"\"+ (Split-Path -Path $SDDCPath -Leaf).Split(".")[0]
$IncompleteSDDC=$False
If(!(Test-Path -Path (Join-Path $SDDCPath 0_CloudHealthSummary.log))){
If(!(Test-Path -Path (Join-Path $SDDCPath 0_CloudHealthGatherTranscript.log))){
Do{ Write-Host " ERROR: Invalid SDDC Path." -ForegroundColor Red
$SDDCPath = Read-Host "Please try again"
$IR+=$IR++
$CluChkReportLoc=Split-Path -Path $SDDCPath
$ExtracLoc=(Split-Path -Path $SDDCPath) +"\"+ (Split-Path -Path $SDDCPath -Leaf).Split(".")[0]
IF($IR -gt 2){
Write-Host " ERROR: Failed SDDC Path too many times. Extracing again." -ForegroundColor Red
$SDDCExtracted="NO"
break
}}
While((!(Test-Path -Path "$SDDCPath\0_CloudHealthSummary.log")))
} else {
$IncompleteSDDC=$True
Write-Host " WARNING: Incomplete SDDC Capture." -ForegroundColor Yellow
gc (Join-Path $SDDCPath 0_CloudHealthGatherTranscript.log) -tail 10 | %{Write-Host " $_ " -ForegroundColor Yellow}
}
}
}
If($SDDCExtracted -ne "YES"){
Write-Host " Please Select-Object SDDC File to use..."
$SDDCLoc=Get-FileName "$env:USERPROFILE\Documents\SRs" "Please Select SDDC File." "ZIP (*.zip)| *.zip"
if(!$SDDCLoc){EndScript}
#Extraction temp location
$CluChkReportLoc=Split-Path -Path $SDDCLoc
$ExtracLoc=(Split-Path -Path $SDDCLoc) +"\"+ (Split-Path -Path $SDDCLoc -Leaf).Split(".")[0]
Try{
If (Test-Path $ExtracLoc -PathType Container){Remove-Item $ExtracLoc -Recurse -Force -ErrorAction Stop | Out-Null}
}Catch{
Write-Host $Oops
Write-Host ""
Write-Host "$Error" -ForegroundColor Red
EndScript
}
if (!(Test-Path $ExtracLoc -PathType Container)) {New-Item -ItemType Directory -Force -Path $ExtracLoc | Out-Null }
Unzip $SDDCLoc $ExtracLoc
$SDDCPath=$ExtracLoc
$IncompleteSDDC=$False
If(!(Test-Path -Path (Join-Path $SDDCPath 0_CloudHealthSummary.log))){
If(!(Test-Path -Path (Join-Path $SDDCPath 0_CloudHealthGatherTranscript.log))){
Write-Host " ERROR: Invalid SDDC Path." -ForegroundColor Red
break
} else {
$IncompleteSDDC=$True
Write-Host " WARNING: Incomplete SDDC Capture." -ForegroundColor Yellow
gc (Join-Path $SDDCPath 0_CloudHealthGatherTranscript.log) -tail 10 | %{Write-Host " $_ " -ForegroundColor Yellow}
}
}
} # if SDDCInputFolder
} else {
if (!(Test-Path -Path $SDDCInputFolder)) {
Write-Host " ERROR: SDDC Path does not exist. Existing" -ForegroundColor Red
EndScript
}
$SDDCPath = $SDDCInputFolder
$CluChkReportLoc=Split-Path -Path $SDDCPath
}
IF($selection -eq "4"){$Global:ProcessSDDC = "N"}
}
#endregion SDDC Locate and Extract
#region Ask for TSRs
#$ProcessTSR = Read-Host "Would you like to process TSRs? [y/n]"
IF($ProcessTSR -ieq "y"){
# Show Tech-Support Report
if ($TSRInputFolder -eq '') {
Write-Host "Please Select Support Assist Collection(TSR) File(s) to use..."
$TSRLOC = Get-FileName "$env:USERPROFILE\Documents\SRs" "Please Select Support Assist Collection(TSR) File(s) to use." ""
} else {
$TSRLOC = $TSRInputFolder
}
If ($TSRLOC.length -eq 0) {
Write-Host " ERROR: Empty path given. Existing" -ForegroundColor Red
EndScript
}
if (!(Test-Path -Path $TSRLOC)) {
Write-Host " ERROR: TSR Path does not exist. Existing" -ForegroundColor Red
EndScript
}
$CluChkReportLoc=(Split-Path -Path $TSRLOC)
}
#endregion End Ask for TSRs
Function Convert-BytesToSize
{
<#
.SYNOPSIS
Converts any integer size given to a user friendly size.
.DESCRIPTION
Converts any integer size given to a user friendly size.
.PARAMETER size
Used to convert into a more readable format.
Required Parameter
.EXAMPLE
ConvertSize -size 134217728
Converts size to show 128MB
#>
#Requires -version 2.0
[CmdletBinding()]
Param
(
[parameter(Mandatory=$False,Position=0)][int64]$Size
)
#Decide what is the type of size
Switch ($Size)
{
{$Size -gt 1PB}
{
Write-Verbose "Convert to PB"
$NewSize = "$([math]::Round(($Size / 1PB),2))PB"
Break
}
{$Size -gt 1TB}
{
Write-Verbose "Convert to TB"
$NewSize = "$([math]::Round(($Size / 1TB),2))TB"
Break
}
{$Size -gt 1GB}
{
Write-Verbose "Convert to GB"
$NewSize = "$([math]::Round(($Size / 1GB),2))GB"
Break
}
{$Size -gt 1MB}
{
Write-Verbose "Convert to MB"
$NewSize = "$([math]::Round(($Size / 1MB),2))MB"
Break
}
{$Size -gt 1KB}
{
Write-Verbose "Convert to KB"
$NewSize = "$([math]::Round(($Size / 1KB),2))KB"
Break
}
Default
{
Write-Verbose "Convert to Bytes"
$NewSize = "$([math]::Round($Size,2))Bytes"
Break
}
}
Return $NewSize
}
#region Create HTML file and adding CSSfor output
#$DateTime=Get-date
$DTString=Get-Date -Format "yyyyMMdd_HHmmss_"
$htmlout=""
$html=""
$ResultsSummary=@()
$htmlStyle = @"
<style TYPE="text/css">
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
TR:Nth-Child(Even) {Background-Color: #dddddd;}
TR:Hover TD {Background-Color: #C1D5F8;}
h5 {display: block;font-size: .83em;margin-top: 0;margin-bottom: 0;margin-left: 0;margin-right: 0;font-weight: normal;padding: 0;}
h1{border-bottom: 5px solid #f4a460}
mark {
background-color: yellow;
color: black;
}
</style>
<script>
function toggle(ele,cElem) {
var cont = document.getElementById(ele);
cont.style.display = cont.style.display == 'none' ? 'block' : 'none';
cElem.innerText = cElem.innerText == '\u21ca\xa0' ? '\u21c9\xa0' : '\u21ca\xa0';
}
</script>
"@
#endregion
Function Set-ResultsSummary{
Param
(
[Parameter(Mandatory=$true, Position=0)]
[string] $Name,
[Parameter(Mandatory=$true, Position=1)]
[string] $html
)
# Add summary info
#$WarningsCount= 0
#$ErrorsCount= 0
$Table =@()
$Table = [PSCustomObject]@{
Name = $name
Warnings = ($html -split '\<\/tr\>' | Where-Object{$_ -imatch 'ffff00'}| Measure-Object).Count
Errors = ($html -split '\<\/tr\>' | Where-Object{($_ -imatch 'ffffff') -or($_ -imatch 'font color="red"')}| Measure-Object).Count
}
return $Table
} #function Set-ResultsSummary
<#
# Download htmlagilitypack
try {
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/HtmlAgilityPack/1.11.46" -OutFile "$env:TEMP\htmlagilitypack.nupkg.zip"
}
catch {
Throw ('Unable to download HTMLAgilityPack')
}
# Find the htmlagilitypack.dll
Expand-Archive "$env:TEMP\htmlagilitypack.nupkg.zip" -DestinationPath "$env:TEMP\htmlagilitypack" -force -ErrorAction SilentlyContinue
#>
<#If ((Get-Job -Name "AgilityPack").State -match 'Running') {
write-host ("Waiting on download job to complete")
$loopTimer = 0
$maxTimer = 150
while (((Get-Job -Name "AgilityPack").State -ne 'Completed') -and ($loopTimer -le $maxTimer)){
Sleep -Milliseconds 100
$loopTimer++
}
}
If ((Get-Job -Name "AgilityPack").State -ne 'Completed') {
Write-Host "Could not download Agility Pack" -ForegroundColor Red
Get-Job -Name "AgilityPack" | Receive-Job
Get-Job | Remove-Job -Force
exit
}
Get-Job | Remove-Job -Force
# Import the required libraries windows 10 or above will have .Net 4.5 or greater. Assuming .Net 4.5 lib
Add-Type -Path (Get-ChildItem -Path "C:\ProgramData\Dell\htmlagilitypack" -Recurse -Filter 'Net45' | Get-ChildItem | Where-Object{$_.Name -imatch 'HtmlAgilityPack.dll'}).fullname
#.Net download -
# $webClient.DownloadFile($URL, $OutFile)}
#>
If ($ProcessSDDC -ieq 'y') {
#$SysInfoFiles=(Get-ChildItem -Path $SDDCPath -Filter "SystemInfo.TXT" -Recurse -Depth 1).FullName
$GetComputerInfo=gci $SDDCPath -Filter "GetComputerInfo.xml" -Recurse -Depth 1 | Import-Clixml
#$SystemInfoData=@()
$SysInfo=@()
<#ForEach($dFile in $SysInfoFiles){ # Changed 06072023
$SystemInfoContent=@()
$SystemInfoContent= Get-Content $dFile
$osInfo=@{}
$SystemInfoContent | Where-Object{($_ -like "OS*") -or ($_ -like "Host Name:*") -or ($_ -like "System Model:*")} | %{try {$osInfo.add($_.split(":")[0].trim(),$_.split(":")[1].trim())} catch {}}
$SysInfo += [PSCustomObject] @{
HostName = $osInfo.'Host Name'
OSVersion = ($osInfo.'OS Version' -split "\s+")[0]
OSBuildNumber = ($osInfo.'OS Version' -split "\s+")[-1]
OSName = $osInfo.'OS Name'.Replace('Microsoft','').Trim() # remove Microsoft
SysModel = $osInfo.'System Model'
}
}#>
ForEach ($osInfo in $GetComputerInfo) {
$SysInfo += [PSCustomObject] @{
HostName = $osInfo.CsCaption
OSVersion = $osInfo.OsVersion
OSBuildNumber = $osInfo.OsBuildNumber
OSName = $osInfo.OSName.Replace('Microsoft','').Trim() # remove Microsoft
SysModel = $osInfo.CsModel
}
}
#Write-Host "Time here is $(((Get-Date)-$dstop).totalmilliseconds)"
#$SysInfo | fl
# determine os version, used later on
$OSVersionNodes = 'Unknown'
# Azure Stack HCI OS versions
If($SysInfo[0].OSName -imatch 'HCI'){
#NOT APEX
IF($SysInfo[0].SysModel -notmatch "^APEX"){
$OSVersionNodes = Switch ($SysInfo[0].OSBuildNumber) {
'19042' {'20H2'}
'20348' {'21H2'}
'20349' {'22H2'}
Default {"RREEDD"+$SysInfo[0].OSBuildNumber}
}
}
#APEX
IF($SysInfo[0].SysModel -match "^APEX"){
$OSVersionNodes = Switch ($SysInfo[0].OSBuildNumber) {
'20349' {'22H2'}
'25398' {'23H2'}
Default {"RREEDD"+$SysInfo[0].OSBuildNumber}
}
}
} else {
# regular Windows Server versions
$OSVersionNodes = Switch ($SysInfo[0].OSBuildNumber) {
'20348' {'2022'}
'17763' {'2019'}
'14393' {'2016'}
Default {"RREEDD"+$SysInfo[0].OSBuildNumber}
}
}}
#region Gather the Support Matrix for Microsoft HCI Solutions
Write-Host " Gathering Support Matrix for Dell EMC Solutions for Microsoft Azure Stack HCI..."
if ($OSVersion -eq "2016" -or $OSversion -match "2012") {$URL='https://dell.github.io/azurestack-docs/docs/hci/supportmatrix/2309/'} else {
#$webClient = [System.Net.WebClient]::new()
$SMRevHistLatest=""
#URL for Dell Technologies Solutions for Microsoft Azure Stack Support Matrix
#$OutFile="$env:TEMP\supmatrix.html"
$SMURL='https://dell.github.io/azurestack-docs/docs/hci/supportmatrix/'
try {
$SMVersion = Invoke-WebRequest $SMURL -UseBasicParsing
}
catch {
Throw ('Unable to download support matrix')
}
#Filter for links "Azure Stack HCI Support Matrix" in the text
$SMLinks = $SMVersion.Links | Where-Object {$_.outerHTML -match "Azure Stack HCI Support Matrix"} | Select-Object -ExpandProperty href
#Select the latest support matrix
$LatestLink=$SMlinks | Sort-Object {[regex]::Matches($_, "(?<=\/)\d+").Value | ForEach-Object {[int]$_}} -Descending | select -First 1
# Remove the trailing forward slash ("/") if it exists
$LatestLink=$LatestLink.trim('/')
#Create a customer object with the revision and link
$resultObject = [PSCustomObject] @{
REVISION = ($LatestLink -split '/')[-1]
LINK = $LatestLink
}
$SMRevHistLatest=$resultObject | Select-Object -Last 1
# Set the URL of the Lastest Support Matrix
#$URL = 'https://dell.github.io/azurestack-docs/docs/hci/supportmatrix/2302/'
$URL = $SMRevHistLatest.link
}
# Download the HTML content of the webpage
try {
$SMresponse = Invoke-WebRequest $URL -UseBasicParsing
#$SMresponse = (new-object System.net.webclient).DownloadString($URL)
}
catch {
Throw ('Unable to download suppot matrix (2)')
}
# Parse the HTML content using HtmlAgilityPack
#$html1 = New-Object HtmlAgilityPack.HtmlDocument
#$html1.LoadHtml($SMresponse.Content)
$html1 = Convert-HtmlTableToPsObject -HtmlContent $SMresponse.Content
# Retrieve all tables from the HTML content
#$tables = $html1.DocumentNode.SelectNodes("//table")
# Loop through each table and retrieve the data
$SupportMatrixtableData = @{}
foreach ($table in $html1.Keys) {
# Retrieve the name of the table from the preceding h3 element
$tableName = $table
# Create an object array to store the table data
$tableArray = @()
# Retrieve the header row of the table, if it exists
$headerData = @()
$headerData = ($html1.$table | gm | ? MemberType -eq NoteProperty).Name
#if ($headerRow) {
# $headerData = $headerRow.Descendants("th") | Select-Object -ExpandProperty InnerText
#}
# Retrieve the data rows of the table
$dataRows = ($html1.$table | Select -Skip 1 | gm | ? MemberType -eq NoteProperty).Name
<#foreach ($row in $dataRows | select -skip 1) {
# Loop through the cells of the row and add them to the table array
$rowData = @{}
$cellIndex = 0
foreach ($cell in $row.Descendants("td")) {
if ($headerData) {
$rowData.Add($headerData[$cellIndex], $cell.InnerText)
} else {
$rowData.Add("Column" + $cellIndex, $cell.InnerText)
}
$cellIndex++
}
$tableArray += $rowData
}#>
# Add the table array to the table data object with the table name as the key
$SupportMatrixtableData.Add($tableName, ($html1.$table | Select-Object -Skip 1))
}
# Convert the table data to XML
$SMxml = $SupportMatrixtableData | ConvertTo-Xml -As String -NoTypeInformation
<#$pageContent = Invoke-WebRequest -Method GET -Uri $url
$SMTableNames=$pageContent.ParsedHtml.getElementsByTagName('h3') | Foreach {$_.InnerText}
$SupportMatrixtableData=@{}
$i=0
foreach ($table in ($pageContent.ParsedHtml.getElementsByTagName('table'))) {
$SupportMatrixtableData.Add($SMTableNames[$i],(ConvertFrom-CSV -Delimiter "``" ($table | Foreach{($_.InnerHTML) -replace "</td>","``" -replace "</th>","``" -replace "`r`n",""`
-split "<tr>" -replace "(<br>)+","," -replace "<[^>]*>",""}))) #Delimeter is backtick
$i++
}#>
#foreach ($a in ($SupportMatrixtableData.'Network Adapters')) {foreach ($b in ($a | gm -MemberType Properties).Name) {if (-not $a.$b) {$a.$b=$c.$b;echo 'Caught it'}} $c=$a}
#endregion Support Matrix
#Report ID
$htmlout+=""
$htmlout+="ReportID: $CReportID"
#region Prcoess Show Tech-Support Report(s)
If($ProcessSTS -ieq 'y'){
# Write-Host "*******************************************************************************"
# Write-Host "* *"
# Write-Host "* Show Tech-Support Report *"
# Write-Host "* *"
# Write-Host "*******************************************************************************"
# Show Tech-Support Report
# Filter Support Matrix for Microsoft HCI Solutions for Switch firmware information from
$SMSwitchFWTable= $SupportMatrixtableData['Network Switches']
$resultObject=@()
Foreach($SMSwitchFW in $SMSwitchFWTable){
$resultObject+= [PSCustomObject] @{
COMPONENT = $SMSwitchFW.'Component'
CATEGORY = $SMSwitchFW.'Category'
"MINIMUM SUPPORTED VERSION" = ($SMSwitchFW.'Minimum Supported Version' -split '-')[0]
}
}
$SMSwitchFWData = $resultObject
<# .Values | Where-Object { $_.'Network Switches' -imatch $platformName}
| Where-Object {$_.innerText -imatch 'S4148F'}
$SMSwitchFWData=@()
ForEach($Row in $SMSwitchFWTable.rows){
#$toggle="off"
$resultObject=@()
$Cells = @($Row.Cells)
IF($Cells.innerText[0] -imatch 'Dell EMC Networking'){
$resultObject=@()
If(($Cells.innerText[3] -split '\/').count -gt 1){
$resultObject+= [PSCustomObject] @{
COMPONENT = (($Cells.innerText[0] -replace '^\s+','') -split '\/')[0]
TYPE = $Cells.innerText[1] -replace '^\s+',''
CATEGORY = $Cells.innerText[2] -replace '^\s+',''
"MINIMUM SUPPORTED VERSION" = ((($Cells.innerText[3] -split '\s\-\s')[0] -replace '\s+','') -split '\/')[0]
}
$resultObject+= [PSCustomObject] @{
COMPONENT = ($Cells.innerText[0] -replace '^\s+','' -replace 'OS9\/')
TYPE = $Cells.innerText[1] -replace '^\s+',''
CATEGORY = $Cells.innerText[2] -replace '^\s+',''
"MINIMUM SUPPORTED VERSION" = ((($Cells.innerText[3] -split '\s\-\s')[0] -replace '\s+','') -split '\/')[1]
}
}Else{
$resultObject+= [PSCustomObject] @{
COMPONENT = $Cells.innerText[0] -replace '^\s+',''
TYPE = $Cells.innerText[1] -replace '^\s+',''
CATEGORY = $Cells.innerText[2] -replace '^\s+',''
"MINIMUM SUPPORTED VERSION" = ($Cells.innerText[3] -split '\s\-\s')[0] -replace '\s+',''
}
}
$SMSwitchFWData += $resultObject
}
}
#>
#$SMSwitchFWData | FT