-
Notifications
You must be signed in to change notification settings - Fork 11
/
VMware.CloudFoundation.Reporting.psm1
10338 lines (8892 loc) · 650 KB
/
VMware.CloudFoundation.Reporting.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
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
# Copyright 2023-2024 Broadcom. All Rights Reserved.
# SPDX-License-Identifier: BSD-2
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Enable communication with self-signed certificates when using Powershell Core. If you require all communications
# to be secure and do not wish to allow communication with self-signed certificates, remove lines 19-39 before
# importing the module.
if ($PSEdition -eq 'Core') {
$PSDefaultParameterValues.Add("Invoke-RestMethod:SkipCertificateCheck", $true)
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
}
if ($PSEdition -eq 'Desktop') {
# Allow communication with self-signed certificates when using Windows PowerShell
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
if ("TrustAllCertificatePolicy" -as [type]) {} else {
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertificatePolicy : ICertificatePolicy {
public TrustAllCertificatePolicy() {}
public bool CheckValidationResult(
ServicePoint sPoint, X509Certificate certificate,
WebRequest wRequest, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertificatePolicy
}
}
##########################################################################
#Region Non Exported Functions ######
Function Get-Password {
param (
[string]$user,
[string]$password
)
if ([string]::IsNullOrEmpty($password)) {
$secureString = Read-Host -Prompt "Enter the password for $user" -AsSecureString
$password = ConvertFrom-SecureString $secureString -AsPlainText
}
return $password
}
#EndRegion Non Exported Functions ######
##########################################################################
#######################################################################################################################
##################################### J S O N O U T P U T V A R I A B L E S #####################################
Set-Variable -Name "backupJsonSuffix" -value "backup-status.json" -scope global
Set-Variable -Name "nsxtTransportJsonSuffix" -value "nsxttransportnode-status.json" -scope global
Set-Variable -Name "nsxttntunnelJsonSuffix" -value "nsxttntunnel-status.json" -scope global
Set-Variable -Name "nsxttier0bgpJsonSuffix" -value "nsxttier0bgp-status.json" -scope global
Set-Variable -Name "snapshotJsonSuffix" -value "snapshot-status.json" -scope global
Set-Variable -Name "localuserexpiryJsonSuffix" -value "localuserexpiry-status.json" -scope global
Set-Variable -Name "storageCapacityHealthJsonSuffix" -value "storagecapacityhealth-status.json" -scope global
Set-Variable -Name "componentConnectivityHealthNonSOSJsonSuffix" -value "componentconnectivityhealthnonsos-status.json" -scope global
Set-Variable -Name "nsxtCombinedHealthNonSOSJsonSuffix" -value "nsxtcombinedhealthnonsos-status.json" -scope global
Set-Variable -Name "cdRomJsonSuffix" -value "cdrom-status.json" -scope global
Set-Variable -Name "esxiConnectionHealthJsonSuffix" -value "esxi-connection-status.json" -scope global
Set-Variable -Name "sddcFreePoolJsonSuffix" -value "sddc-manager-free-pool-status.json" -scope global
############################## E N D O F J S O N O U T P U T V A R I A B L E S ##############################
#######################################################################################################################
#######################################################################################################################
################################## C O M P O N E N T S I Z E V A R I A B L E S ##################################
Set-Variable -Name "vcsaSize" -Value '[
{
"name": "tiny",
"resources": {
"cpu": 2,
"memory": 12
},
"maximum": {
"hosts": 10,
"vms": 100
}
},
{
"name": "small",
"resources": {
"cpu": 4,
"memory": 19
},
"maximum": {
"hosts": 100,
"vms": 1000
}
},
{
"name": "medium",
"resources": {
"cpu": 8,
"memory": 28
},
"maximum": {
"hosts": 400,
"vms": 4000
}
},
{
"name": "large",
"resources": {
"cpu": 16,
"memory": 37
},
"maximum": {
"hosts": 1000,
"vms": 10000
}
},
{
"name": "extra-large",
"resources": {
"cpu": 24,
"memory": 56
},
"maximum": {
"hosts": 3000,
"vms": 30000
}
}
]' -Scope Global
Set-Variable -Name 'nsxLocalManagerSize' -Value '[
{
"name": "extra-small",
"resources": {
"cpu": 2,
"memory": 8
}
},
{
"name": "small",
"resources": {
"cpu": 4,
"memory": 16
}
},
{
"name": "medium",
"resources": {
"cpu": 6,
"memory": 24
}
},
{
"name": "large",
"resources": {
"cpu": 12,
"memory": 48
}
}
]' -Scope Global
Set-Variable -Name 'nsxEdgeSize' -Value '[
{
"name": "small",
"resources": {
"cpu": 2,
"memory": 4
}
},
{
"name": "medium",
"resources": {
"cpu": 4,
"memory": 8
}
},
{
"name": "large",
"resources": {
"cpu": 8,
"memory": 32
}
},
{
"name": "extra-large",
"resources": {
"cpu": 16,
"memory": 64
}
}
]' -Scope Global
########################### E N D O F C O M P O N E N T S I Z E V A R I A B L E S ###########################
#######################################################################################################################
#######################################################################################################################
############################# C O M B I N E D O P E R A T I O N S F U N C T I O N S ############################
Function Invoke-VcfHealthReport {
<#
.SYNOPSIS
Perform health checks
.DESCRIPTION
The Invoke-VcfHealthReport provides a single cmdlet to perform health checks across a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfHealthReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -sddcManagerLocalUser vcf -sddcManagerLocalPass VMw@re1! -reportPath F:\Reporting -allDomains
This example runs a health check across a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfHealthReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -sddcManagerLocalUser vcf -sddcManagerLocalPass VMw@re1! -reportPath F:\Reporting -workloadDomain sfo-w01
This example runs a health check for a specific workload domain within a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfHealthReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -sddcManagerLocalUser vcf -sddcManagerLocalPass VMw@re1! -reportPath F:\Reporting -allDomains -failureOnly
This example runs a health check across a VMware Cloud Foundation instance but only ouputs issues to the HTML report.
.PARAMETER sddcManagerFqdn
The fully qualified domain name of the SDDC Manager.
.PARAMETER sddcManagerUser
The username to authenticate to the SDDC Manager.
.PARAMETER sddcManagerPass
The password to authenticate to the SDDC Manager.
.PARAMETER sddcManagerLocalUser
The username to authenticate to the SDDC Manager appliance.
.PARAMETER sddcManagerLocalPass
The password to authenticate to the SDDC Manager appliance.
.PARAMETER reportPath
The path to save the policy report.
.PARAMETER allDomains
Switch to run health checks across all workload domains.
.PARAMETER workloadDomain
The name of the workload domain to run against.
.PARAMETER failureOnly
Switch to only output issues to the report.
.PARAMETER darkMode
Switch to enable dark mode for the report.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerFqdn,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerUser,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$sddcManagerPass,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerLocalUser,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$sddcManagerLocalPass,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$reportPath,
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$darkMode
)
$sddcManagerPass = Get-Password -user $sddcManagerUser -password $sddcManagerPass
$sddcManagerLocalPass = Get-Password -user $sddcManagerLocalUser -password $sddcManagerLocalPass
Try {
Clear-Host; Write-Host ""
if ($PSVersionTable.PSEdition -eq "Desktop" -or $PSVersionTable.OS -like "Microsoft Windows*") {
$tarPath = (Get-Command tar -ErrorAction SilentlyContinue).Source
if (!($tarPath)) {
Write-Warning "The tar utility is required to run this cmdlet. Please check the module system requirements and try again."
return
}
}
if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType health # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
if ($PsBoundParameters.ContainsKey("allDomains")) {
$reportname = $defaultReport.Split('-health')[0] + "-health-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
$reportData = "<h1>SDDC Manager: $sddcManagerFqdn</h1>"
$workflowMessage = "VMware Cloud Foundation instance ($sddcManagerFqdn)"
$commandSwitch = "-allDomains"
} else {
$reportname = $defaultReport.Split('.')[0] + "-" + $workloadDomain + ".htm"
$reportData = "<h1>Workload Domain: $workloadDomain</h1>"
$workflowMessage = "Workload Domain ($workloadDomain)"
$commandSwitch = "-workloadDomain $workloadDomain"
}
if ($PsBoundParameters.ContainsKey('failureOnly')) {
$failureOnlySwitch = " -failureOnly"
}
$vcfVersion = ((Get-VCFManager).version).Split('-')[0]
Start-SetupLogFile -Path $reportPath -ScriptName $MyInvocation.MyCommand.Name # Setup Log Location and Log File
Write-LogMessage -Type INFO -Message "Starting the process of creating a Health Report for $workflowMessage." -Colour Yellow
Write-LogMessage -Type INFO -Message "Setting up the log file to path $logfile."
Write-LogMessage -Type INFO -Message "Setting up report folder and report $reportName."
Write-LogMessage -Type INFO -Message "Running an SoS Health Check for $workflowMessage, process takes time."
$jsonFilePath = Invoke-Expression "Request-SoSHealthJson -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -reportPath $reportFolder $($commandSwitch)"
# Generating the Service Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the Service Health Report using the SoS output for $workflowMessage."
$serviceHtml = Invoke-Expression "Publish-ServiceHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $serviceHtml
# Generating the Version Health Data Using the SoS Data
if ($vcfVersion -ge "4.5.0") {
Write-LogMessage -Type INFO -Message "Generating the Version Health Report using the SoS output for $workflowMessage."
$versionHtml = Invoke-Expression "Publish-VersionHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $versionHtml
}
# Generating the Hardware Compatibility Health Data Using the SoS Data
Write-LogMessage -type INFO -Message "Generating the Hardware Compatibility Health Report using the SoS output for $workflowMessage."
$hardwareCompatibilityHtml = Invoke-Expression "Publish-HardwareCompatibilityHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $hardwareCompatibilityHtml
# Generating the Connectivity Health Data Using SoS Data and Supplemental PowerShell Request Functions
Write-LogMessage -Type INFO -Message "Generating the Connectivity Health Report using the SoS output for $workflowMessage."
$componentConnectivityHtml = Invoke-Expression "Publish-ComponentConnectivityHealth -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -json $jsonFilePath $($commandSwitch) $($failureOnlySwitch)"; $reportData += $componentConnectivityHtml
# Generating the Password Expiry Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the Password Expiry Report for $workflowMessage."
$passwordHtml = Invoke-Expression "Publish-PasswordHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $passwordHtml
# Generating the Certificate Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the Certificate Health Report using the SoS output for $workflowMessage."
$certificateHtml = Invoke-Expression "Publish-CertificateHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $certificateHtml
# Generating the Backup Status Health Data Using PowerShell Request Functions
Write-LogMessage -Type INFO -Message "Generating the Backup Status Report for $workflowMessage."
$backupStatusHtml = Invoke-Expression "Publish-BackupStatus -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch) $($failureOnlySwitch)"; $reportData += $backupStatusHtml
# Generating the Snapshot Status Health Data Using PowerShell Request Functions
Write-LogMessage -type INFO -Message "Generating the Snapshots Report for $workflowMessage."
$snapshotStatusHtml = Invoke-Expression "Publish-SnapshotStatus -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch) $($failureOnlySwitch)"; $reportData += $snapshotStatusHtml
# Generating the DNS Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the DNS Health Report using the SoS output for $workflowMessage."
$dnsHtml = Invoke-Expression "Publish-DnsHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $dnsHtml
# Generating the NTP Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the NTP Health Report using the SoS output for $workflowMessage."
$ntpHtml = Invoke-Expression "Publish-NtpHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $ntpHtml
# Generating the vCenter Server Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the vCenter Server Health Report using the SoS output for $workflowMessage."
$vcenterHtml = Invoke-Expression "Publish-VcenterHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $vcenterHtml
# Generating the ESXi Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the ESXi Health Report using the SoS output for $workflowMessage."
$esxiHtml = Invoke-Expression "Publish-EsxiHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $esxiHtml
# Generating the ESXi Connection Health Data Using PowerShell Request Functions
Write-LogMessage -type INFO -Message "Generating the ESXi Connection Health Data report for $workflowMessage."
$esxiConnectionHtml = Invoke-Expression "Publish-EsxiConnectionHealth -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch) $($failureOnlySwitch)"; $reportData += $esxiConnectionHtml
# Generating the Free Pool Health Data Using PowerShell Request Functions
Write-LogMessage -type INFO -Message "Generating the SDDC Manager Free Pool Health for $workflowMessage."
$freePoolHtml = Invoke-Expression "Publish-SddcManagerFreePool -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($failureOnlySwitch)"; $reportData += $freePoolHtml
# Generating the vSAN Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the vSAN Health Report using the SoS output for $workflowMessage."
$vsanHtml = Invoke-Expression "Publish-VsanHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $vsanHtml
# Generating the vSAN Storage Policy Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the vSAN Storage Policy Health Report using the SoS output for $workflowMessage."
$vsanPolicyHtml = Invoke-Expression "Publish-VsanStoragePolicy -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $vsanPolicyHtml
# Generating the NSX Manager Health Data Using SoS output and Supplemental PowerShell Request Functions
Write-LogMessage -Type INFO -Message "Generating the NSX Health Report using the SoS output for $workflowMessage."
$nsxtHtml = Invoke-Expression "Publish-NsxtCombinedHealth -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -json $jsonFilePath $($commandSwitch) $($failureOnlySwitch)"; $reportData += $nsxtHtml
# Generating the NSX Edge Cluster Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the NSX Edge Cluster Health Report using the SoS output for $workflowMessage."
$nsxtEdgeClusterHtml = Invoke-Expression "Publish-NsxtEdgeClusterHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $nsxtEdgeClusterHtml
# Generating the NSX Edge Node Health Data Using the SoS Data
Write-LogMessage -Type INFO -Message "Generating the NSX Edge Node Health Report using the SoS output for $workflowMessage."
$nsxtEdgeNodeHtml = Invoke-Expression "Publish-NsxtEdgeNodeHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $nsxtEdgeNodeHtml
# Generating the NSX Transport Node Health Data Using PowerShell Request Functions
Write-LogMessage -type INFO -Message "Generating the NSX Transport Node Report for $workflowMessage."
$nsxTransportNodeHtml = Invoke-Expression "Publish-NsxtTransportNodeStatus -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch) $($failureOnlySwitch)"; $reportData += $nsxTransportNodeHtml
# Generating the NSX Transport Node Tunnel Health Data Using PowerShell Request Functions
Write-LogMessage -type INFO -Message "Generating the NSX Transport Node Tunnel Report for $workflowMessage."
$nsxTransportNodeTunnelHtml = Invoke-Expression "Publish-NsxtTransportNodeTunnelStatus -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch) $($failureOnlySwitch)"; $reportData += $nsxTransportNodeTunnelHtml
# Generating the NSX Tier-0 Gateway BGP Health Data Using PowerShell Request Functions
Write-LogMessage -type INFO -Message "Generating the NSX Tier-0 Gateway BGP Report for $workflowMessage."
$nsxTier0BgpHtml = Invoke-Expression "Publish-NsxtTier0BgpStatus -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch) $($failureOnlySwitch)"; $reportData += $nsxTier0BgpHtml
# Generating the Disk Capacity Health Data Using PowerShell Request Functions
Write-LogMessage -Type INFO -Message "Generating the Disk Capacity Report for $workflowMessage.'"
$storageCapacityHealthHtml = Invoke-Expression "Publish-StorageCapacityHealth -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -localUser $sddcManagerLocalUser -localPass $sddcManagerLocalPass $($commandSwitch) $($failureOnlySwitch)"; $reportData += $storageCapacityHealthHtml
# Generating the Virtual Machines with Connected CD-ROM Health Data Using PowerShell Request Functions
Write-LogMessage -type INFO -Message "Generating the Virtual Machines with Connected CD-ROM Report for $workflowMessage."
$vmConnectedCdromHtml = Invoke-Expression "Publish-VmConnectedCdrom -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $vmConnectedCdromHtml
if ($PsBoundParameters.ContainsKey("darkMode")) { $reportHeader = Get-ClarityReportHeader -dark } else { $reportHeader = Get-ClarityReportHeader }
$reportNavigation = Get-ClarityReportNavigation -reportType health
$reportFooter = Get-ClarityReportFooter
$report = $reportHeader
$report += $reportNavigation
$report += $reportData
$report += $reportFooter
# Generate the report to an HTML file and then open it in the default browser
Write-LogMessage -Type INFO -Message "Generating the final report and saving to ($reportName)."
$report | Out-File $reportName
if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -ne "Linux") {
Invoke-Item $reportName
} elseif ($PSEdition -eq "Desktop") {
Invoke-Item $reportName
}
}
}
} Catch {
Debug-CatchWriter -object $_
}
}
Export-ModuleMember -Function Invoke-VcfHealthReport
Function Invoke-VcfAlertReport {
<#
.SYNOPSIS
Generates the alert report for a VMware Cloud Foundation instance.
.DESCRIPTION
The Invoke-VcfAlertReport provides a single cmdlet to generates the alert report for a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfAlertReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -allDomains
This example generates the alert report across a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfAlertReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -allDomains -failureOnly
This example generates the alert report across a VMware Cloud Foundation instance but for only failed items.
.EXAMPLE
Invoke-VcfAlertReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -workloadDomain sfo-w01
This example generates the alert report for a specific workload domain in a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfAlertReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -workloadDomain sfo-w01 -failureOnly
This example generates the alert report for a specific workload domain in a VMware Cloud Foundation instance but for only failed items.
.PARAMETER sddcManagerFqdn
The fully qualified domain name of the SDDC Manager.
.PARAMETER sddcManagerUser
The username to authenticate to the SDDC Manager.
.PARAMETER sddcManagerPass
The password to authenticate to the SDDC Manager.
.PARAMETER reportPath
The path to save the policy report.
.PARAMETER allDomains
Switch to run against all workload domains.
.PARAMETER workloadDomain
The name of the workload domain to run against.
.PARAMETER failureOnly
Switch to only output issues to the report.
.PARAMETER darkMode
Switch to enable dark mode for the report.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerFqdn,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerUser,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$sddcManagerPass,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$reportPath,
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$darkMode
)
$sddcManagerPass = Get-Password -user $sddcManagerUser -password $sddcManagerPass
Try {
Clear-Host; Write-Host ""
if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType alert # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
if ($PsBoundParameters.ContainsKey("allDomains")) {
$reportname = $defaultReport.Split('-alert')[0] + "-alert-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
$reportData = "<h1>SDDC Manager: $sddcManagerFqdn</h1>"
$workflowMessage = "VMware Cloud Foundation instance ($sddcManagerFqdn)"
$commandSwitch = "-allDomains"
} else {
$reportname = $defaultReport.Split('.')[0] + "-" + $workloadDomain + ".htm"
$reportData = "<h1>Workload Domain: $workloadDomain</h1>"
$workflowMessage = "Workload Domain ($workloadDomain)"
$commandSwitch = "-workloadDomain $workloadDomain"
}
if ($PsBoundParameters.ContainsKey('failureOnly')) {
$commandSwitch = $commandSwitch + " -failureOnly"
}
Start-SetupLogFile -Path $reportPath -ScriptName $MyInvocation.MyCommand.Name # Setup Log Location and Log File
Write-LogMessage -Type INFO -Message "Starting the process of creating an Alert Report for $workflowMessage." -Colour Yellow
Write-LogMessage -Type INFO -Message "Setting up the log file to path $logfile."
Write-LogMessage -Type INFO -Message "Setting up report folder and report $reportName."
# Generate vCenter Server Alerts Using PowerShell Function
Write-LogMessage -Type INFO -Message "Generating the vCenter Server alerts for $workflowMessage."
$vCenterAlertHtml = Invoke-Expression "Publish-VcenterAlert -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $vCenterAlertHtml
# Generate ESXi Alerts Using PowerShell Function
Write-LogMessage -type INFO -Message "Generating the ESXi host alerts for $workflowMessage."
$esxiAlertHtml = Invoke-Expression "Publish-EsxiAlert -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $esxiAlertHtml
# Generate vSAN Alerts Using PowerShell Function
Write-LogMessage -type INFO -Message "Generating the vSAN alerts for $workflowMessage."
$vsanAlertHtml = Invoke-Expression "Publish-VsanAlert -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $vsanAlertHtml
# Generate NSX Alerts Using PowerShell Function
Write-LogMessage -type INFO -Message "Generating the NSX alerts for $workflowMessage."
$nsxtAlertHtml = Invoke-Expression "Publish-NsxtAlert -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $nsxtAlertHtml
if ($PsBoundParameters.ContainsKey("darkMode")) {
$reportHeader = Get-ClarityReportHeader -dark
} else {
$reportHeader = Get-ClarityReportHeader
}
$reportNavigation = Get-ClarityReportNavigation -reportType alert
$reportFooter = Get-ClarityReportFooter
$report = $reportHeader
$report += $reportNavigation
$report += $reportData
$report += $reportFooter
# Generate the report to an HTML file and then open it in the default browser
Write-LogMessage -Type INFO -Message "Generating the final report and saving to ($reportName)."
$report | Out-File $reportName
if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -ne "Linux") {
Invoke-Item $reportName
} elseif ($PSEdition -eq "Desktop") {
Invoke-Item $reportName
}
}
}
} Catch {
Debug-CatchWriter -object $_
}
}
Export-ModuleMember -Function Invoke-VcfAlertReport
Function Invoke-VcfConfigReport {
<#
.SYNOPSIS
Generates the configuration report
.DESCRIPTION
The Invoke-VcfConfigReport provides a single cmdlet to generates a configuration report for a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfConfigReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -allDomains
This example generates the configuration report across a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfConfigReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -workloadDomain sfo-w01
This example generates the configuration report for a specific workload domain within a VMware Cloud Foundation instance.
.PARAMETER sddcManagerFqdn
The fully qualified domain name of the SDDC Manager.
.PARAMETER sddcManagerUser
The username to authenticate to the SDDC Manager.
.PARAMETER sddcManagerPass
The password to authenticate to the SDDC Manager.
.PARAMETER reportPath
The path to save the policy report.
.PARAMETER allDomains
Switch to run against all workload domains.
.PARAMETER workloadDomain
The name of the workload domain to run against.
.PARAMETER failureOnly
Switch to only output issues to the report.
.PARAMETER darkMode
Switch to enable dark mode for the report.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerFqdn,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerUser,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$sddcManagerPass,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$reportPath,
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$darkMode
)
$sddcManagerPass = Get-Password -user $sddcManagerUser -password $sddcManagerPass
Try {
Clear-Host; Write-Host ""
if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType config # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
if ($PsBoundParameters.ContainsKey("allDomains")) {
$reportname = $defaultReport.Split('-config')[0] + "-config-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
$reportData = "<h1>SDDC Manager: $sddcManagerFqdn</h1>"
$workflowMessage = "VMware Cloud Foundation instance ($sddcManagerFqdn)"
$commandSwitch = "-allDomains"
} else {
$reportname = $defaultReport.Split('.')[0] + "-" + $workloadDomain + ".htm"
$reportData = "<h1>Workload Domain: $workloadDomain</h1>"
$workflowMessage = "Workload Domain ($workloadDomain)"
$commandSwitch = "-workloadDomain $workloadDomain"
}
Start-SetupLogFile -Path $reportPath -ScriptName $MyInvocation.MyCommand.Name # Setup Log Location and Log File
Write-LogMessage -Type INFO -Message "Starting the Process of Creating a Configuration Report for $workflowMessage." -Colour Yellow
Write-LogMessage -Type INFO -Message "Setting up the log file to path $logfile."
Write-LogMessage -Type INFO -Message "Setting up report folder and report $reportName."
# Collecting Cluster Configuration Using PowerShell Functions
Write-LogMessage -Type INFO -Message "Generating the Cluster Configuration for $workflowMessage."
$clusterConfigHtml = Invoke-Expression "Publish-ClusterConfiguration -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $clusterConfigHtml
# Collecting Cluster DRS Rules Using PowerShell Functions
Write-LogMessage -Type INFO -Message "Generating the DRS Rule Configuration for $workflowMessage."
$clusterDrsRuleHtml = Invoke-Expression "Publish-ClusterDrsRule -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $clusterDrsRuleHtml
# Collecting Resource Pool Details Using PowerShell Functions
Write-LogMessage -Type INFO -Message "Generating the Resouce Pool Configuration for $workflowMessage."
$resourcePoolsHtml = Invoke-Expression "Publish-ResourcePool -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $resourcePoolsHtml
# Collecting VM Overrides Using PowerShell Functions
Write-LogMessage -Type INFO -Message "Generating the VM Override Configuration for $workflowMessage."
$vmOverridesHtml = Invoke-Expression "Publish-VmOverride -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $vmOverridesHtml
# Collecting Virtual Networking Using PowerShell Functions
Write-LogMessage -Type INFO -Message "Generating the Virtual Networking Configuration for $workflowMessage."
$virtualNetworkHtml = Invoke-Expression "Publish-VirtualNetwork -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $virtualNetworkHtml
# Collecting ESXi Security Configuration Using PowerShell Functions
Write-LogMessage -Type INFO -Message "Generating the ESXi Security Configuration for $workflowMessage."
$esxiSecurityHtml = Invoke-Expression "Publish-EsxiSecurityConfiguration -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass $($commandSwitch)"; $reportData += $esxiSecurityHtml
if ($PsBoundParameters.ContainsKey("darkMode")) {
$reportHeader = Get-ClarityReportHeader -dark
} else {
$reportHeader = Get-ClarityReportHeader
}
$reportNavigation = Get-ClarityReportNavigation -reportType config
$reportFooter = Get-ClarityReportFooter
$report = $reportHeader
$report += $reportNavigation
$report += $reportData
$report += $reportFooter
# Generate the report to an HTML file and then open it in the default browser
Write-LogMessage -Type INFO -Message "Generating the Final Report and Saving to ($reportName)."
$report | Out-File $reportName
if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -ne "Linux") {
Invoke-Item $reportName
} elseif ($PSEdition -eq "Desktop") {
Invoke-Item $reportName
}
}
}
} Catch {
Debug-CatchWriter -object $_
}
}
Export-ModuleMember -Function Invoke-VcfConfigReport
Function Invoke-VcfUpgradePrecheck {
<#
.SYNOPSIS
Perform upgrade precheck
.DESCRIPTION
The Invoke-VcfUpgradePrecheck runs an upgrade precheck for a workload domain
.EXAMPLE
Invoke-VcfUpgradePrecheck -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -workloadDomain sfo-w01
This example runs a health check for a specific workload domain within an SDDC Manager instance.
.PARAMETER sddcManagerFqdn
The fully qualified domain name of the SDDC Manager.
.PARAMETER sddcManagerUser
The username to authenticate to the SDDC Manager.
.PARAMETER sddcManagerPass
The password to authenticate to the SDDC Manager.
.PARAMETER reportPath
The path to save the policy report.
.PARAMETER workloadDomain
The name of the workload domain to run against.
.PARAMETER darkMode
Switch to enable dark mode for the report.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerFqdn,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerUser,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$sddcManagerPass,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$reportPath,
[Parameter (ParameterSetName = 'Specific--WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$darkMode
)
$sddcManagerPass = Get-Password -user $sddcManagerUser -password $sddcManagerPass
Try {
Clear-Host; Write-Host ""
if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType upgrade # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
$reportname = $defaultReport.Split('-upgrade')[0] + "-upgrade-" + $workloadDomain + ".htm"
$workflowMessage = "Workload Domain ($workloadDomain)"
Start-SetupLogFile -Path $reportPath -ScriptName $MyInvocation.MyCommand.Name # Setup Log Location and Log File
Write-LogMessage -Type INFO -Message "Starting the Process of Running an Upgrade Precheck for $workflowMessage." -Colour Yellow
Write-LogMessage -Type INFO -Message "Setting up the log file to path $logfile."
Write-LogMessage -Type INFO -Message "Setting up report folder and report $reportName."
if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$jsonSpec = '{ "resources" : [ { "resourceId" : "'+ (Get-VCFWorkloadDomain | Where-Object {$_.name -eq $workloadDomain}).id+'", "type" : "DOMAIN" } ] }'
$task = Start-VCFSystemPrecheck -json $jsonSpec
Write-LogMessage -Type INFO -Message "Waiting for Upgrade Precheck Task ($($task.name)) with Id ($($task.id)) to Complete."
Do { $status = Get-VCFSystemPrecheckTask -id $task.id } While ($status.status -eq "IN_PROGRESS")
Write-LogMessage -Type INFO -Message "Task ($($task.name)) with Task Id ($($task.id)) completed with status ($($status.status))."
$allChecksObject = New-Object System.Collections.ArrayList
foreach ($subTask in $status.subTasks) {
$elementObject = New-Object -TypeName psobject
$elementObject | Add-Member -NotePropertyName 'Component' -NotePropertyValue $subTask.resources.type
if ($subTask.resources.type -eq "ESX") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFHost -id $subTask.resources.resourceId).fqdn
} elseif ($subTask.resources.type -eq "VCENTER") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFvCenter -id $subTask.resources.resourceId).fqdn
} elseif ($subTask.resources.type -eq "CLUSTER") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFCluster -id $subTask.resources.resourceId).name
} elseif ($subTask.resources.type -eq "VSAN") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFCluster -id $subTask.resources.resourceId).primaryDatastoreName
} elseif ($subTask.resources.type -eq "DEPLOYMENT_CONFIGURATION") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFManager -id $subTask.resources.resourceId).fqdn
} elseif ($subTask.resources.type -eq "VRSLCM") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFvRSLCM -id $subTask.resources.resourceId).fqdn
} elseif ($subTask.resources.type -eq "VROPS") {
$id = $subTask.resources.resourceId + ":vrops"
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFvROPS | Where-Object {$_.id -eq $id}).loadBalancerFqdn
} elseif ($subTask.resources.type -eq "VRLI") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFvRLI -id $subTask.resources.resourceId).loadBalancerFqdn
} elseif ($subTask.resources.type -eq "VRA") {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue (Get-VCFvRA -id $subTask.resources.resourceId).loadBalancerFqdn
} else {
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue $subTask.resources.resourceId
}
$elementObject | Add-Member -NotePropertyName 'Precheck Task' -NotePropertyValue $subTask.name
if ($subTask.status -eq "SUCCESSFUL") {
$alert = "GREEN"
} elseif ($subTask.status -eq "WARNING") {
$alert = "YELLOW"
} elseif ($subTask.status -eq "FAILED") {
$alert = "RED"
}
$elementObject | Add-Member -NotePropertyName 'Alert' -NotePropertyValue $alert
$allChecksObject += $elementObject
}
$allChecksObject = $allChecksObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '<a id="upgrade-precheck"></a><h3>Upgrade Precheck</h3>' -As Table
$allChecksObject = Convert-CssClass -htmldata $allChecksObject
}
}
# Combine all information gathered into a single HTML report
$reportData = "<h1>Workload Domain: $workloadDomain</h1>"
$reportData += $allChecksObject
if ($PsBoundParameters.ContainsKey("darkMode")) {
$reportHeader = Get-ClarityReportHeader -dark
} else {
$reportHeader = Get-ClarityReportHeader
}
$reportNavigation = Get-ClarityReportNavigation -reportType upgrade
$reportFooter = Get-ClarityReportFooter
$report = $reportHeader
$report += $reportNavigation
$report += $reportData
$report += $reportFooter
# Generate the report to an HTML file and then open it in the default browser
Write-LogMessage -Type INFO -Message "Generating the Final Report and Saving to ($reportName)."
$report | Out-File $reportName
if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -ne "Linux") {
Invoke-Item $reportName
} elseif ($PSEdition -eq "Desktop") {
Invoke-Item $reportName
}
}
}
} Catch {
Debug-CatchWriter -object $_
}
}
Export-ModuleMember -Function Invoke-VcfUpgradePrecheck
Function Invoke-VcfOverviewReport {
<#
.SYNOPSIS
Generates the system overview report
.DESCRIPTION
The Invoke-VcfOverviewReport provides a single cmdlet to generates a system overview report for a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfOverviewReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting
This example generates the system overview report for a VMware Cloud Foundation instance.
.EXAMPLE
Invoke-VcfOverviewReport -sddcManagerFqdn sfo-vcf01.sfo.rainpole.io -sddcManagerUser admin@local -sddcManagerPass VMw@re1!VMw@re1! -reportPath F:\Reporting -anonymized
This example generates the system overview report for a VMware Cloud Foundation instance, but will anonymize the output.
.PARAMETER sddcManagerFqdn
The fully qualified domain name of the SDDC Manager.
.PARAMETER sddcManagerUser
The username to authenticate to the SDDC Manager.
.PARAMETER sddcManagerPass
The password to authenticate to the SDDC Manager.
.PARAMETER reportPath
The path to save the policy report.
.PARAMETER darkMode
Switch to enable dark mode for the report.
.PARAMETER anonymized
Switch to enable anonymized output for the report.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerFqdn,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerUser,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$sddcManagerPass,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$reportPath,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$darkMode,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$anonymized
)
$sddcManagerPass = Get-Password -user $sddcManagerUser -password $sddcManagerPass
Try {
Clear-Host; Write-Host ""
if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType overview # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
$reportname = $defaultReport.Split('-overview')[0] + "-overview-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
$workflowMessage = "VMware Cloud Foundation instance ($sddcManagerFqdn)"
Start-SetupLogFile -Path $reportPath -ScriptName $MyInvocation.MyCommand.Name # Setup Log Location and Log File
Write-LogMessage -Type INFO -Message "Starting the Process of Creating a System Overview Report for $workflowMessage." -Colour Yellow
Write-LogMessage -Type INFO -Message "Setting up the log file to path $logfile."
Write-LogMessage -Type INFO -Message "Setting up report folder and report $reportName."
if ($PsBoundParameters.ContainsKey("anonymized")) {
Write-LogMessage -Type INFO -Message "Generating Anonymized System Overview Report for $workflowMessage."
$vcfOverviewHtml = Publish-VcfSystemOverview -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -anonymized
} else {
Write-LogMessage -Type INFO -Message "Generating System Overview Report for $workflowMessage."
$vcfOverviewHtml = Publish-VcfSystemOverview -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass
}
$reportData += $vcfOverviewHtml
if ($PsBoundParameters.ContainsKey("darkMode")) {
$reportHeader = Get-ClarityReportHeader -dark
} else {
$reportHeader = Get-ClarityReportHeader
}
$reportNavigation = Get-ClarityReportNavigation -reportType overview
$reportFooter = Get-ClarityReportFooter
$report = $reportHeader
$report += $reportNavigation
$report += $reportData
$report += $reportFooter
# Generate the report to an HTML file and then open it in the default browser
Write-LogMessage -Type INFO -Message "Generating the Final Report and Saving to ($reportName)."
$report | Out-File $reportName
if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -ne "Linux") {
Invoke-Item $reportName
} elseif ($PSEdition -eq "Desktop") {
Invoke-Item $reportName
}
}
}
} Catch {
Debug-CatchWriter -object $_
}
}
Export-ModuleMember -Function Invoke-VcfOverviewReport
########################################## E N D O F F U N C T I O N S ##########################################
#######################################################################################################################
#######################################################################################################################
############################# S O S J S O N E X T R A C T I O N F U N C T I O N S ############################
Function Request-SoSHealthJson {
<#
.SYNOPSIS
Run SoS and save the JSON output.
.DESCRIPTION
The Request-SoSHealthJson cmdlet connects to SDDC Manager, runs an SoS Health collection to JSON, and saves the
JSON file to the local file system.
.EXAMPLE
Request-SoSHealthJson -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -reportPath F:\Reporting\HealthReports -allDomains
This example runs an SoS Health collection for all domains in the SDDC and saves the JSON output to the local file system.
.EXAMPLE
Request-SoSHealthJson -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -reportPath F:\Reporting\HealthReports -workloadDomain sfo-w01
This example runs an SoS Health collection for a workload domain in the SDDC and saves the JSON output to the local file system.
.PARAMETER server
The fully qualified domain name of the SDDC Manager.
.PARAMETER user
The username to authenticate to the SDDC Manager.
.PARAMETER pass
The password to authenticate to the SDDC Manager.
.PARAMETER reportPath
The path to save the policy report.
.PARAMETER allDomains
Switch to run against all workload domains.
.PARAMETER workloadDomain
The name of the workload domain to run against.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$user,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$pass,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$reportPath,
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain
)
$pass = Get-Password -user $user -password $pass
# Request VCF Token
Request-VCFToken -fqdn $server -Username $user -Password $pass -skipCertificateCheck -ErrorAction SilentlyContinue -ErrorVariable ErrMsg | Out-Null
$vcfVersion = ((Get-VCFManager).version).Split('-')[0]
# Build Default Health Summary Check POST payload
$healthChecksPayload = New-Object -TypeName psobject
$healthChecksPayload | Add-Member -notepropertyname 'certificateHealth' -notepropertyvalue $true
if ($vcfVersion -lt "5.2.0") {$healthChecksPayload | Add-Member -notepropertyname 'composabilityHealth' -notepropertyvalue $true }
$healthChecksPayload | Add-Member -notepropertyname 'computeHealth' -notepropertyvalue $true
$healthChecksPayload | Add-Member -notepropertyname 'connectivityHealth' -notepropertyvalue $true
$healthChecksPayload | Add-Member -notepropertyname 'dnsHealth' -notepropertyvalue $true
$healthChecksPayload | Add-Member -notepropertyname 'generalHealth' -notepropertyvalue $true
$healthChecksPayload | Add-Member -notepropertyname 'hardwareCompatibilityHealth' -notepropertyvalue $true
$healthChecksPayload | Add-Member -notepropertyname 'ntpHealth' -notepropertyvalue $true
$healthChecksPayload | Add-Member -notepropertyname 'passwordHealth' -notepropertyvalue $true
$healthChecksPayload | Add-Member -notepropertyname 'servicesHealth' -notepropertyvalue $true