Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Upgrade vCenter Server Appliance (VCSA) with VMware PowerCLI

I had bunch of vCenter Server appliance (VCSA) to update/upgrade. Although the upgrade process using vCenter Server VAMI portal (5480) is fairly very simple and easy as shown in Patching update VMware vCenter Server Appliance from a zipped update bundle Web server. But I wanted it to get it automated so once I assign task to my juniors they make less mistakes.

Note: Before starting upgrade of VCSA make sure you take either backup of VCSA Backup VMware vCenter server using SMB protocol or snapshot of VCSA VM Create List or Remove VMware VM Snapshots with PowerCLi to avoid any problems.

To use this script make sure you install VMware PowerCLI on PowerShell using command Install-Module VMware.PowerCLI -Scope CurrentUser

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Write-Host "vCenter authentication information" -BackgroundColor Yellow
$vCenter = 'dccomics.vcloud-lab.com'  
$username = '[email protected]'   
$password = '123456'  

Write-Host "Login to vCenter" -BackgroundColor Yellow
Connect-CisServer -Server $vCenter -User $username -Password $password

Write-Host "Get CIS Service for pending updates" -BackgroundColor Yellow
$updateService = Get-CisService -Name "com.vmware.appliance.update.pending"
$availableVersions = $updateService.list("LOCAL_AND_ONLINE")

Write-Host "Get available latest version" -BackgroundColor Yellow
$latestVersion = $availableVersions.version | Sort-Object -Descending | Select-Object -First 1 -ExpandProperty Value

Write-Host "Stage and install latest version" -BackgroundColor Yellow
$userData = $updateService.help.stage_and_install.user_data.Create()
$userData.add('id', $latestVersion)
$updateService.stage_and_install($latestVersion,$userData)

After running this script make sure you do not login to VAMI portal at all for next 120 minutes. Update is happening in the background. I found when I was trying to see the process/progress it was getting stuck or halt between 90% to 98% progress. This looks like bug - when we make https call to VAMI or refresh the page, upgrade process get stopped or stuck.

Additionally I found there is dedicated module to update VCSA using PowerCLI, you can download the module using command Install-Module -Name VMware.Community.VCSA.Update -Scope CurrentUser

Download this script Update-vCenterCis.ps1 here or it is also available on github.com/janviudapi.

VMware PowerCLI PowerShell vsphere esxi vCenter server appliance vcsa update upgrade settings configuration check updates settings reboot required cisservice connect-cisserver png

Useful Articles
Registering HPE ILO amplifier pack (Hardware support manager) with vCenter 7 Lifecycle manager
VMware LifeCycle Manager import updates bundle and patch ESXi server
How to update a patch on an ESXi host via command line
Add a Trusted Root Certificate to the Certificate Store VMware Photon OS
Patching update VMware vCenter Server Appliance from a zipped update bundle Web server
Powershell GUI VMware ESXi custom patch bundle builder
Create a custom TCPIP stack on ESXi server - VMware PowerCLI GUI

Go Back

Comment

Blog Search

Page Views

12063586

Follow me on Blogarama