-
Notifications
You must be signed in to change notification settings - Fork 0
/
Update-vRSLCMPSPack.ps1
95 lines (87 loc) · 5.89 KB
/
Update-vRSLCMPSPack.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
Function Update-vRSLCMPSPack {
<#
.SYNOPSIS
Refresh Product Support Packs and Install.
.DESCRIPTION
The Update-vRSLCMPSPack cmdlet refreshes the available Product Support Packs and installs the required version
to VMware Aria Suite Lifecycle. The cmdlet connects to SDDC Manager using the -server, -user, and -password
values.
- Validates that network connectivity and authentication is possible to SDDC Manager
- Validates that Aria Suite Lifecycle has been deployed in VCF-aware mode and retrieves its details
- Validates that network connectivity and authentication is possible to VMware Aria Suite Lifecycle
.EXAMPLE
Update-vRSLCMPSPack -server sfo-vcf01.sfo.rainpole.io -user [email protected] -pass VMw@re1! -psPack PSPACK6
This example refreshes the available Product Support Packs and installs the required version to VMware Aria Suite Lifecycle.
.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 psPack
The Product Support Pack to install.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$user,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$psPack
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$psPackFile
)
Try {
if (Test-VCFConnection -server $server) {
if (Test-VCFAuthentication -server $server -user $user -pass $pass) {
if (($vcfVrslcmDetails = Get-vRSLCMServerDetail -fqdn $server -username $user -password $pass)) {
if (Test-vRSLCMConnection -server $vcfVrslcmDetails.fqdn) {
if (Test-vRSLCMAuthentication -server $vcfVrslcmDetails.fqdn -user $vcfVrslcmDetails.adminUser -pass $vcfVrslcmDetails.adminPass) {
if ($psPack) {
$request = Get-vRSLCMPSPack -checkOnline
Start-Sleep 3
Do { $getStatus = (Get-vRSLCMRequest $request.requestId).state } Until ($getStatus -ne "INPROGRESS")
if ($getStatus -eq "COMPLETED") {
$allPsPacks = Get-vRSLCMPSPack
$pspackId = ($allPsPacks | Where-Object { $_.fileName -like "*$psPack" }).pspackId
if ($pspackId) {
$vcenterDetails = Get-vRSLCMDatacenterVcenter -datacenterVmid (Get-vRSLCMDatacenter).dataCenterVmid
$request = Start-vRSLCMSnapshot -vcenterFqdn $vcenterDetails.vCenterHost -vcenterName $vcenterDetails.vCenterName -username $vcenterDetails.vcUsername
Start-Sleep 3
Do { $getStatus = (Get-vRSLCMRequest $request.requestId).state } Until ($getStatus -ne "INPROGRESS")
if ($getStatus -eq "COMPLETED") {
Start-Sleep 3
$request = Install-vRSLCMPSPack -pspackId $pspackId
Do { $getStatus = (Get-vRSLCMRequest $request.requestId).state } Until ($getStatus -ne "INPROGRESS")
Write-Output "Product Support Pack ($psPack) install started on VMware Aria Suite Lifecycle ($($vcfVrslcmDetails.fqdn)): SUCCESSFUL"
} else {
Write-Error "VMware Aria Suite Lifecycle Snapshot Task ($($getStatus.vmid)) finished with state ($($getStatus)): POST_VALIDATION_FAILED"
}
} else {
Write-Warning "Product Support Pack ($psPack) not found or already installed in VMware Aria Suite Lifecycle"
}
} else {
Write-Error "VMware Aria Suite Lifecycle Product Support Pack Check Task ($($getStatus.vmid)) finished with state ($($getStatus)): POST_VALIDATION_FAILED"
}
}
if ($psPackFile) {
if (Test-Path -Path $psPackFile) {
$request = Import-vRSLCMPSPack -psPackFile $psPackFile
Start-Sleep 3
Do { $getStatus = (Get-vRSLCMRequest $request.requestId).state } Until ($getStatus -ne "INPROGRESS")
if ($getStatus -eq "COMPLETED") {
Write-Output "Product Support Pack ($psPack) Import to VMware Aria Suite Lifecycle ($($vcfVrslcmDetails.fqdn)): SUCCESSFUL"
} else {
Write-Error "Product Support Pack ($psPack) Import to VMware Aria Suite Lifecycle ($($vcfVrslcmDetails.fqdn)): POST_VALIDATION_FAILED"
}
} else {
Write-Error "Unable to locate the Product Support Pack ($psPackFil): POST_VALIDATION_FAILED"
}
}
}
}
}
}
}
} Catch {
Debug-ExceptionWriter -object $_
}
}
Export-ModuleMember -Function Update-vRSLCMPSPack