WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
    • VMware Cloud Foundation 9
  • VKS
  • Homelab
    • Hardware Options
    • Hardware Reviews
    • Lab Deployment Scripts
    • Nested Virtualization
    • Homelab Podcasts
  • VMware Nostalgia
  • Apple
You are here: Home / vSphere Kubernetes Service / Creating Custom Virtual Machine Classes using vSphere API

Creating Custom Virtual Machine Classes using vSphere API

03.24.2026 by William Lam // Leave a Comment

Back in 2020, the vSphere UI was the only way to create your own custom Virtual Machine Classes, there was not a vSphere API and while you can directly connect to vSphere Supervisor Control Plane, it was not officially supported 🙂


With the release of vSphere 7.0 Update 2, the vSphere Automation REST API has been enhanced to include APIs for managing VM Classes.

A question recently came up about automating custom VM Classes. While the user referenced my earlier blog post, I realized I had not revisited this topic using the updated vSphere REST API. This was a great opportunity to provide a working example and timely, as I had just got access to Cursor.

To demonstrate the use of the vSphere Automation REST API for managing VM Classes, I have created ... or rather, I prompted Cursor to create me a PowerShell script NamespaceVirtualMachineClass.ps1 that contains the following function definitions:

  • Connect-VSphereAutomationSession
  • Disconnect-VSphereAutomationSession
  • Get-NamespaceVirtualMachineClass
  • New-NamespaceVirtualMachineClass
  • Remove-NamespaceVirtualMachineClass

After downloading the PowerShell script, you will need to source the file by running the following command:

. .\NamespaceVirtualMachineClass.ps1

Login to vCenter Server REST API endpoint by providing the FQDN of your vCenter Server and valid credentials

$session = Connect-VSphereAutomationSession -Server sfo-m01-vc01.sfo.rainpole.io -Credential (Get-Credential)

To list all VM Classes, run the following command and provide the $session variable:

Get-NamespaceVirtualMachineClass -Session $session | ft


To create new custom VM Classes, run the following example commands and provide the $session variable:

New-NamespaceVirtualMachineClass -Session $session -CpuCount 32 -MemoryMB 98304 -Name postgres-large -Description "PostgresDB Prod"
New-NamespaceVirtualMachineClass -Session $session -CpuCount 16 -MemoryMB 49152 -Name postgres-medium -Description "PostgresDB Test"
New-NamespaceVirtualMachineClass -Session $session -CpuCount 8 -MemoryMB 16384 -Name postgres-small -Description "PostgresDB Dev"


If we re-run the Get-NamespaceVirtualMachineClass, we can see our newly created custom VM Classes.


To remove VM Classes, run the following command along with the VM Class name and provide the $session variable:

Remove-NamespaceVirtualMachineClass -Session $session -Name postgres-large
Remove-NamespaceVirtualMachineClass -Session $session -Name postgres-medium
Remove-NamespaceVirtualMachineClass -Session $session -Name postgres-small

The VM Classes have been enhanced further with the release of vSphere 9.0 and you now have the ability to add additional devices and

Categories // vSphere Kubernetes Service, vSphere Supervisor Tags // VCF 9.0

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Automating VCF 9.0 Single Sign-On (SSO) with OIDC-based Identity Provider 04/10/2026
  • Automating Lab Optimizations for Post-Deployment of VMware Cloud Foundation (VCF) 04/06/2026
  • Maximizing vSAN ESA Performance on Minisforum MS-A2 03/31/2026
  • Creating Custom Virtual Machine Classes using vSphere API 03/24/2026
  • VCF Installer Deploying VVF Components with VCF Entitlements 03/17/2026

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.

To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2026

 

Loading Comments...