Updating the vCenter Server Appliance (VCSA) with PowerCLI - Revisited
In previous blogs, I covered how to update your VCSA using PowerCLI and with Postman. I also had multiple code sessions at VMworld 2019 where I got great feedback on the module. It’s been a while since I have looked at the module, and time has passed so I thought it was due for an update. The module will no longer need to be manually imported, it is now located in the Powershell Gallery!
VMware {code} Power Session Covering the Module!
Introduction
Using tools such as Postman can make it utilizing API’s a bit easier, but you still need to be familiar with a separate tool or UI. I was able to develop my own version and build my first Powershell Module that you can use to patch the VCSA in a simple method. Some of the function names below may not be 100% exact and this is due to the accepted verbs for Powershell. If you have further recommendations I would be happy to entertain changing the Powershell verbage.
Use Cases
Why would you want to use a Powershell module such as this? Well this tool can support multiple vCenter Servers. So here are a few ideas…,
- Modify a Custom URL Repository Across all vCenter Servers in your Environment
- Stage Patches across all vCenter Servers in your Environment.
- Patch Multiple Servers Simultaneously
Exploring the Powershell Module Functions
As of current, the Powershell module currently has 12 Functions.
- Copy-VCSAUpdate
- Get-VCSAUpdate
- Get-VCSAUpdateDetail
- Get-VCSAUpdatePolicy
- Set-VCSAUpdatePolicy
- Get-VCSAUpdateStaged
- Get-VCSAUpdateStatus
- Remove-VCSAUpdate
- Start-VCSAUpdateInstall
- Start-VCSAUpdatePrecheck
- Start-VCSAUpdateStageandInstall
- Start-VCSAUpdateValidate
- Stop-VCSAUpdate
Copy-VCSAUpdate
Copy-VCSAUpdate is the command you will use when you want to manually stage the update.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Copy-VCSAUpdate -Version "6.7.0.20100"
Get-VCSAUpdate
Get-VCSAUpdate is the command you will use when you want to wish to check for new updates. There is an optional Parameter for Source, “Local” or “Online”, if no parameter is chosen it will default to Online.
Examples:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Get-VCSAUpdate
3
4Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
5Get-VCSAUpdate -Source "Online"
6
7Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
8Get-VCSAUpdate -Source "Local"
Get-VCSAUpdateDetail
Get-VCSAUpdateDetail is the command you will use when you want to wish to get more details about a specific update. There is a mandatory parameter for Version.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Get-VCSAUpdateDetail -Version "6.7.0.20100"
Get-VCSAUpdatePolicy
Get-VCSAUpdatePolicy is the command you will use when you want to wish to get information about the current appliance update settings.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Get-VCSAUpdatePolicy
Set-VCSAUpdatePolicy
Set-VCSAUpdatePolicy is the command you will use when you want to wish to set information for the current appliance update settings.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Set-VCSAUpdatePolicy -AutoStage $True
3
4Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
5Set-VCSAUpdatePolicy -CustomURL https://myinternalURL.com
6Set-VCSAUpdatePolicy -CustomURL Clear
7
8Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
9Set-VCSAUpdatePolicy -UsernameURL admin
10Set-VCSAUpdatePolicy -PasswordURL Password
11
12Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
13Set-VCSAUpdatePolicy -CheckSchedule Daily
14Set-VCSAUpdatePolicy -CheckSchedule WeeklySunday
15Set-VCSAUpdatePolicy -CheckSchedule WeeklyMonday
16Set-VCSAUpdatePolicy -CheckSchedule WeeklyTuesday
17Set-VCSAUpdatePolicy -CheckSchedule WeeklyWednesday
18Set-VCSAUpdatePolicy -CheckSchedule WeeklyThursday
19Set-VCSAUpdatePolicy -CheckSchedule WeeklyFriday
20Set-VCSAUpdatePolicy -CheckSchedule WeeklySaturday
Get-VCSAUpdateStaged
Get-VCSAUpdateStaged is the command you will use when you want to wish to get information about the current staged update.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Get-VCSAUpdateStaged
Get-VCSAUpdateStatus
Get-VCSAUpdateStaged is th e command you will use when you want to wish to get information about the current update status. This command can be used to get status of staged update, install update or any other update status.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Get-VCSAUpdateStatus
Remove-VCSAUpdate
Remove-VCSAUpdate is the command you will use when you wish to remove a staged update.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Remove-VCSAUpdate
Start-VCSAUpdateInstall
Start-VCSAUpdateInstall is the command you will use when you wish to install a currently staged update. If no update is staged you must use Start-VCSAUpdateStageandInstall
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Start-VCSAUpdateInstall -Version "6.7.0.20100" -SSODomainPass "VMware1!"
Start-VCSAUpdatePrecheck
Start-VCSAUpdatePrecheck is the command you will use when you wish to run the built-in update Precheck.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Start-VCSAUpdatePrecheck -Version "6.7.0.20100"
Start-VCSAUpdateStageandInstall
Start-VCSAUpdateStageandInstall is the command you will use when you wish to install and stage an update.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Start-VCSAUpdateStageandInstall -Version "6.7.0.20100" -SSODomainPass "VMware1!"
Start-VCSAUpdateValidate
Start-VCSAUpdateValidate is the command you will use when you wish validate the current update.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Start-VCSAUpdateValidate -Version "6.7.0.20100" -SSODomainPass "VMware1!"
Stop-VCSAUpdate
Stop-VCSAUpdate is the command you will use when you want to cancel an update task such as staging an update or other task that has a status of cancelable.
Example:
1Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
2Stop-VCSAUpdate
Putting the Powershell Module to Use
This Examples assumes your VCSA has Internet Access and we will update via the Online Repo.
You can access the Powershell Module here on the Powershell Gallery.
Important Note: The code samples included in this module are not supported by VMware. The code included is only provided as sample code for the purpose of demonstrating different tasks using the PowerCLI and the REST API.
1Install-Module -Name VMware.Community.VCSA.Update #Install the Module
2Get-VCSAUpdate #Check for Updates
3Copy-VCSAUpdate -Version "7.0.0.10300" #Stages the Update
4Get-VCSAUpdateStatus #Check status until `UPDATE_PENDING`
5Start-VCSAUpdatePrecheck -Version 7.0.0.10300 #Run Update Precheck
6Start-VCSAUpdateValidate -Version 7.0.0.10300 -SSODomainPass VMware1! #Run Update Validate
7Start-VCSAUpdateInstall -Version 7.0.0.10300 -SSODomainPass VMware1! #Run Update Install
8Get-VCSAUpdateStatus` # Check status until `UPDATE_COMPLETE`
Conclusion
I hope this module can be useful for you to get started with updating your VCSA in a more Automated fashion.
If you have any questions feel free to reach out here or on twitter @davidstamen
comments powered by DisqusSee Also
- Patching the vCenter Server Appliance (VCSA) using the REST API - Part 2 (PowerCLI Module)
- Patching the vCenter Server Appliance (VCSA) using the REST API - Part 1 (Postman Collection)
- Installing and Updating the Pure Storage vSphere Plugin
- Windows Server 2008 is Going EOL - What about my vCenter Server?
- vCenter Server Converge Tool - What About My Certificates