This PowerShell helps to fetch the current version of VCSA (VMware vCenter Server Appliance). This information is useful while automating VCSA upgrade, It is fetched used from VCSA REST API.
In the vCenter Server Management portal you can see the Version in the update.
You can download this script Show-VCSACurrentVersion.ps1 here or it is also available on github.com.
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 |
# vCenter Update Script # created by vCloud-Lab.lab # This script checks current version on a vCenter Server using the REST API. # Requires PowerShell 7 or newer param ( [string]$vcServer = "marvel.vcloud-lab.com", [string]$vcUser = "[email protected]", [string]$vcPass = "Computer@123" ) [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } # Get session ID using username/password function Get-VCenterSession { $authUri = "https://$vcServer/rest/com/vmware/cis/session" $authBytes = [System.Text.Encoding]::UTF8.GetBytes("${vcUser}:${vcPass}") $authHeader = "Basic " + [System.Convert]::ToBase64String($authBytes) $headers = @{ "Authorization" = $authHeader "Content-Type" = "application/json" } $response = Invoke-RestMethod -Uri $authUri -Method Post -Headers $headers -SkipCertificateCheck return $response.value } # Get appliance update status function Get-ApplianceUpdateStatus { param ( [string]$vcServer, [string]$sessionId ) $uri = "https://$vcServer/api/appliance/update" $headers = @{ "vmware-api-session-id" = $sessionId } try { $result = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers -SkipCertificateCheck Write-Host "🔍 Appliance Update Status:" Write-Host "Latest Query Time : $($result.latest_query_time)" Write-Host "Current State : $($result.state)" Write-Host "Installed Version : $($result.version)" } catch { Write-Warning "⚠️ Failed to retrieve appliance update status: $($_.Exception.Message)" } } # --- MAIN --- try { $session = Get-VCenterSession if (-not $session) { throw "❌ Could not authenticate with vCenter." } Get-ApplianceUpdateStatus -vcServer $vcServer -sessionId $session } catch { Write-Error "❌ ERROR: $($_.Exception.Message)" } finally { if ($session) { $logoutUri = "https://$vcServer/rest/com/vmware/cis/session" Invoke-RestMethod -Method Delete -Uri $logoutUri -Headers @{ "vmware-api-session-id" = $session } -SkipCertificateCheck Write-Host "🔒 Session logged out." } } |
Useful Articles
Install VMware VCSA Patch Upgrade using PowerCLI vCenter REST API
Configure, Manage and Assign License Settings for VMware vCenter Server and ESXi
Administrating licenses in vSphere client
Assign vSAN licenses in vSphere client
Solved: VMware Snapshots Virtual Machines disks consolidation is needed
Performing vCenter Offline Updates Via Your On-Prem Web Server Securely & Seamlessly
Configure VCSA Update Web Repository Settings with PowerShell and REST API
Reset vCenter Server Appliance (VCSA) Forgotten Root Password Without Reboot
How to install Ansible on Linux for vSphere configuration
Using Ansible for Managing VMware vsphere Infrastructure


