Skip to content

Automating vSphere Foundation 9.1 through vCenter: PowerCLI, Terraform and change ownership

A vSphere Foundation team that automates through vCenter has to settle one thing before the first script writes to production: which tool or person owns each kind of object, under which identity, and with which record of state. Our recommendation is to hold the first production terraform apply until an ownership table, a separate identity per pipeline and a locked remote state exist, each with evidence, as the closing checklist lists. The baseline here is vSphere Foundation 9.1.1 with vCenter 9.1.1.0100, build 25784172, and ESX 9.1.1.0100, build 25782009, both released on October 12, 202612, automated with VCF PowerCLI 9.1.13 and the Terraform vsphere provider 2.17.14.

Broadcom states that VCF PowerCLI continues VMware.PowerCLI and that existing cmdlets, modules and scripts keep working3. The vsphere provider 2.17.1 was released on September 14, 20265, and its documentation lists vSphere 9.x and 8.x as supported4.

What vSphere Foundation includes, and which tools fall away

Broadcom’s feature comparison of July 15, 2026, describes vSphere Foundation as vSphere, vSphere Kubernetes Service, VCF Operations and vSAN, some in limited versions, while VMware Cloud Foundation adds VCF Operations for networks, fleet management, VCF Automation and NSX. It marks vSphere Lifecycle Manager, Content Library, vSphere Configuration Profiles and vCenter Orchestration and Extensibility for vSphere Foundation. The VCF Automation Terraform provider and Git integration are VCF features, and Configuration Drift Management, listed as deprecated, has no vSphere Foundation mark6. The 9.1.1 Bill of Materials lists vCenter, ESX, VCF Operations and the license server at 9.1.1.07.

That removes most of the VMware Terraform family. The vcfa provider needs VCF Automation and the nsxt provider needs NSX, and neither product is part of vSphere Foundation6. What remains is the vsphere provider and the vSphere cmdlets in PowerCLI, both working against vCenter.

Sign-in narrows too. Connect-VIServer has parameter sets for a VCF SSO API token and a VCF SSO OAuth security context, meant for a vCenter federated with VCF SSO8. The feature comparison gives vSphere Foundation single sign-on through the vSphere interface and reserves single sign-on through the VCF Operations interface for VCF6. A vSphere Foundation pipeline therefore signs in as a vCenter user from the identity source or federated provider vCenter uses, as set out in the vSphere Foundation identity and access design, together with the risk of scripts that send passwords to the API.

Write the ownership table before the first apply

Broadcom and HashiCorp document what each tool can change, not which one should own an object. Our recommendation is an ownership table, filled in before any state exists, that names one writer per object class, with a standing rule that any other change to those objects is logged as an exception.

The vsphere provider manages virtual machines, standard and distributed switches, datastores and content libraries4, and import is documented for existing virtual machines9. Host configuration most easily gets two writers. vSphere Configuration Profiles keeps a cluster’s desired host configuration as a JSON document, checks host compliance against it and remediates hosts that drift. It cannot be deactivated once enabled, and Host Profiles is deprecated as of vSphere Foundation 9.010. The provider’s vsphere_configuration_profile resource writes that same configuration from a reference host or a JSON document, needs vCenter 8 or later, and leaves the cluster unchanged when the resource is deleted11. Choose one: the vSphere Client or the Terraform resource. Whether to turn the feature on is covered in the cluster and host design for vSphere Foundation 9.1.

Licensing stays out of Terraform. The vsphere_license resource and the license argument of vsphere_host handle license keys1213, while KB 437250 says vSphere Foundation 9.x licensing is managed through VCF Operations and the VCF Business Services Console, with subscription license files in place of the 25-character keys. The comparison marks vSphere Kubernetes Service, VM Service, vSphere Pod Service and Supervisor Independent Updates for vSphere Foundation6. The Supervisor needs an owner before it exists, because vsphere_supervisor_v2 does not yet support update or import14. Our recommendation is to give it to the vSphere Client from the start.

Roles can be written with vsphere_role, which documents import by role ID15, and permissions with vsphere_entity_permissions, whose page has no import section16. Decide up front whether permissions live in Terraform or the vSphere Client. Orchestration is a writer too. The comparison marks vCenter Orchestration and Extensibility for vSphere Foundation6, so confirm the entitlement for orchestrator workflows before they go into the table. PowerCLI fits reports, inventory exports and one-off bulk changes, under a read-only identity for reports and a named change identity for anything that writes.

One writer per object classAn example ownership table for vSphere Foundation automation. Virtual machines go to Terraform state, with import documented for virtual machines. Cluster host configuration goes to vSphere Configuration Profiles in the vSphere Client or to the Terraform profile resource, never both. Licenses are license files in VCF Operations, not the key-based license resource. Roles and permissions get one writer chosen up front: the role resource documents import by role ID, while the permissions resource has no import section. The Supervisor gets an owner before creation, because Terraform cannot yet update or import it. Reports and one-off bulk changes go to PowerCLI scripts, with a read-only identity for reports.Who writes each objectOne writer per object class, decided before the first applyObject classWriterVirtual machinesTerraform stateImport is documented for VMsCluster hostconfigurationvSphere Configuration Profiles or theTerraform profile resource, never bothLicensesLicense files in VCF OperationsNot the key-based license resourceRoles andpermissionsOne writer chosen up frontRoles import by ID, permissions do notSupervisorOwner chosen before creationNo Terraform update or import yetReports, one-offbulk changesPowerCLI scriptsRead-only identity for reports One writer per object classAn example ownership table for vSphere Foundation automation. Virtual machines go to Terraform state, with import documented for virtual machines. Cluster host configuration goes to vSphere Configuration Profiles in the vSphere Client or to the Terraform profile resource, never both. Licenses are license files in VCF Operations, not the key-based license resource. Roles and permissions get one writer chosen up front: the role resource documents import by role ID, while the permissions resource has no import section. The Supervisor gets an owner before creation, because Terraform cannot yet update or import it. Reports and one-off bulk changes go to PowerCLI scripts, with a read-only identity for reports.Who writes each objectOne writer per object class,decided before the first applyVirtual machinesTerraform stateImport is documented for VMsCluster host configurationvSphere Configuration Profilesor the Terraform profileresource, never bothLicensesLicense files in VCF OperationsNot the key-based license resourceRoles and permissionsOne writer chosen up frontRoles import by ID,permissions do notSupervisorOwner chosen before creationNo Terraform update or import yetReports, one-off bulk changesPowerCLI scriptsRead-only identity for reports
Figure 1. An ownership table for vSphere Foundation automation gives each object class one writer.

VCF PowerCLI 9.1.1 against vCenter

The package to install is VCF.PowerCLI, from the PowerShell Gallery with Install-Module -Name VCF.PowerCLI or from the offline ZIP file. An offline installation cannot later be updated online. Broadcom recommends removing the old VMware.PowerCLI module first and changing module imports in existing scripts to the new name. A system that still has VMware.PowerCLI 13.3 or earlier needs the AllowClobber parameter, because some cmdlets moved between modules17.

The 9.1.1 compatibility matrix lists PowerShell 7.0.13 or later with no upper bound, says Windows PowerShell 5.1 is deprecated in VCF PowerCLI 9.0, and refers to the Broadcom interoperability matrix for vCenter and ESX versions18. The installation guide names PowerShell 7.4 or later as the minimum recommended version17, but Microsoft’s support for PowerShell 7.4 ends on November 10, 2026, and the current LTS release, PowerShell 7.6, is supported until November 14, 202819. Build new runners on 7.6, which falls inside the PowerCLI range.

Certificate checking is on by default. The InvalidCertificateAction setting starts as Unset, which acts as Fail, while Ignore connects whatever the certificate. On PowerShell 7, only Fail and Ignore are supported20. Leave it at Fail and make the runner trust vCenter’s certificate authority instead. KB 330833 describes the download for client machines, which suits a runner too: a ZIP file of the root certificates and revocation lists in the VMware Endpoint Certificate Store, to be imported again after a renewal, regeneration or upgrade issues new certificates.

Set-PowerCLIConfiguration -InvalidCertificateAction Fail -Scope Session -Confirm:$false
Connect-VIServer -Server vcenter01.example.com -Credential $pipelineCredential

In that example the credential object comes from the CI secret store at run time, and -Confirm:$false on Set-PowerCLIConfiguration is a precaution: its page documents no confirmation prompt, but a runner without a console must never stop at one. Connect-VIServer marks passing credentials through PowerShell pipeline input and the Session parameter as deprecated, and SaveCredentials is not supported on PowerShell 78. -Scope Session keeps the setting to the current run, overriding user and all-users settings on that runner20.

The vsphere provider: endpoint, trust and secrets

The provider’s vsphere_server argument is the vCenter FQDN or address4. Cloning, OVF and OVA deployment, tags and custom attributes on virtual machines all require vCenter and are not supported on direct ESX connections9, so a state points at vCenter and never at a host. The provider has Partner tier status: bug reports go to its GitHub project, and a formal support case goes through the Broadcom support portal under the product VMware ESXi and the component VCF Terraform21.

allow_unverified_ssl defaults to false, and the documentation warns that turning it on could let an attacker intercept the authentication token. The abridged example at the top of the same page sets it to true4, so copy the provider block from your own template, not from that example. Adding hosts follows the same rule: vsphere_host accepts a SHA-1 thumbprint, and without one the CA that signed the host certificate must be trusted, or the operation fails13.

The user name and password are required arguments and can come from the VSPHERE_USER and VSPHERE_PASSWORD environment variables4. If secret values are written into the configuration, Terraform keeps them in state and plan files. Terraform 1.10 and later can mark a variable as ephemeral, which omits it from both, and ephemeral values may be used in a provider block22. Because the password is not in a saved plan file, the job that applies the plan has to supply it again.

terraform {
  required_version = ">= 1.10"
  required_providers {
    vsphere = {
      source  = "vmware/vsphere"
      version = "2.17.1"
    }
  }
}

variable "vsphere_user" {
  type = string
}

variable "vsphere_password" {
  type      = string
  sensitive = true
  ephemeral = true
}

provider "vsphere" {
  vsphere_server       = "vcenter01.example.com"
  user                 = var.vsphere_user
  password             = var.vsphere_password
  allow_unverified_ssl = false
}

The required_providers entry pins the tested provider version, and the dependency lock file, .terraform.lock.hcl, which Terraform updates on each init, records what was installed. HashiCorp recommends keeping it in version control23, so a provider upgrade shows up as a reviewed change instead of a silent change on the runner.

The provider does not close its sessions when its process ends, so a busy pipeline without persistence can reach vCenter’s concurrent-session limit. Persisting sessions to disk avoids that, but the provider warns that session keys are as good as user credentials while they are valid4. Either accept more short-lived sessions, or persist them and protect the session directory like the password.

Pipeline identities and vCenter privileges

vCenter’s guidance for roles and permissions applies to pipeline accounts. Assign roles to groups rather than users, grant permissions only on the objects where they are needed, group objects into folders so permissions can be set per folder, and be careful with permissions on the root objects, which expose roles, custom attributes and vCenter settings24. A Terraform account that builds virtual machines needs propagating rights on the VM folders, resource pools, datastores and networks it uses, and no administrative role at the root. Privilege Recorder, below, shows the read access it needs higher up.

Some provider privileges are easy to miss. It always reads tags, even on resources without any, and it reads events to detect guest customization and power events. Some operations need StorageProfile.View to read storage policies, and virtual machines need VirtualMachine.Config.SwapPlacement because the provider sets a default swap placement policy4.

Privilege Recorder lists the privilege checks made during a workflow, with session, user, managed object and operation ID, so a role can be built from the minimum set used. It is a REST API only, records only scripted workflows and has no UI25. Give every Terraform state an account that no other state shares, so each change in vCenter’s events leads back to one pipeline. The cost is more accounts to rotate. For audits, the vSphere Client exports the permissions of any object to a CSV file26.

State, locking and approving a plan

By default Terraform keeps state in a local terraform.tfstate file, which a team cannot share safely. Remote state on a backend fixes that, and fully featured backends also lock the state against concurrent runs27. Locking is automatic for every operation that could write state, and HashiCorp advises keeping it on. Its force-unlock command is for freeing your own lock after automatic unlocking failed, since freeing another run’s lock can leave two writers on one state28.

State and plan files can hold passwords and tokens. Remote backends hold state in memory only while it is in use, and encryption at rest depends on the backend22. A saved plan file contains the full configuration, the input variables and every planned value, in cleartext, even where the terminal output hides them29. Keep plan files short-lived, with the same access control as the state.

The saved plan is also the unit of approval. terraform plan -out writes a plan file that terraform apply later executes, and -detailed-exitcode returns 0 for an empty plan, 1 for an error and 2 when changes are present29. A CI job can stop on 1, record a 0 and route a 2 to review. When the error is a state lock held by another run, leave that lock to its owner. prevent_destroy rejects plans that would destroy a protected object, but it does not protect an object whose resource block is deleted from the configuration30. Approval rules therefore read the plan. A plan that destroys or replaces an object goes to a second approver and a maintenance window, as does an in-place change that the provider documents as rebooting the virtual machine, such as a change of firmware, hardware version, cores per socket or PCI device. If the guest does not shut down within shutdown_wait_timeout, three minutes by default, the provider forces a power-off, because force_power_off defaults to true, and with it set to false the apply returns an error instead9. Our recommendation is false in production unless the application owner accepts a hard power-off. Other changes need one reviewer, and changes no reviewed code change explains are treated as out-of-band edits until investigated.

Routing a saved plan by its exit codeA plan is saved to a file with detailed exit codes. Exit code 1 is an error: stop, read the error and leave a held state lock to its owner. Exit code 0 means no changes: record the result. Exit code 2 means changes are present. If the changes do not come from a reviewed code change, they are treated as an out-of-band change until investigated: run a refresh-only apply to accept it and then update the code, or apply to revert it. If they do come from a reviewed code change, check whether the plan destroys or replaces objects or makes an in-place change that reboots a virtual machine. If it does, a second approver and a maintenance window are needed. If not, one reviewer approves. Either way, the saved plan file is then applied.Routing a saved planPlan saved to a file, with detailed exit codesSaved planExit 1: errorExit 0: no changesExit 2: changesStop, read the error,leave a held lockto its ownerRecord theresultChanges from areviewed codechange?NoYesTreat as out-of-band:refresh-only apply to accept it,then update the code,or apply to revert itDestroys, replaces orreboots a VM?YesNoSecond approverand a windowOne reviewerapprovesApply the saved plan file Routing a saved plan by its exit codeA plan is saved to a file with detailed exit codes. Exit code 1 is an error: stop, read the error and leave a held state lock to its owner. Exit code 0 means no changes: record the result. Exit code 2 means changes are present. If the changes do not come from a reviewed code change, they are treated as an out-of-band change until investigated: run a refresh-only apply to accept it and then update the code, or apply to revert it. If they do come from a reviewed code change, check whether the plan destroys or replaces objects or makes an in-place change that reboots a virtual machine. If it does, a second approver and a maintenance window are needed. If not, one reviewer approves. Either way, the saved plan file is then applied.Routing a saved planPlan saved to a file,with detailed exit codesSaved planExit 1: errorStop, read the error, leavea held lock to its ownerExit 0: no changesRecord the resultExit 2: changesChanges from a reviewedcode change?No: treat as out-of-band.Refresh-only apply to accept it,then update the code,or apply to revert itYes: does it destroy, replaceor reboot a VM?Yes: secondapprover, windowNo: onereviewer approvesApply the saved plan file
Figure 2. A saved plan is routed by its exit code, its origin and whether it destroys, replaces or reboots anything.

Importing existing objects and catching drift

Each existing object comes in through an import block with the object’s ID, paired with a resource block at the same address, which terraform plan -generate-config-out can draft31. The flag is marked experimental29, so read the generated code before merging it.

Virtual machines import by their full inventory path, including the vm folder and any subfolders. Disks must be labeled by their order on the SCSI bus, starting at Hard Disk 0, custom labels are lost on import, and a VM without a storage controller cannot be imported. Disks come in with keep_on_remove enabled until the first apply. The provider expects only configuration-level changes in the first plan after import, and the clone block must not be changed before the first apply9. Clusters import by their path as well32. With import blocks the import itself happens at apply31, so our recommendation is to hold the plan carrying the import blocks to that expectation before applying, and to plan again afterward to confirm that nothing was reconfigured. Import lab virtual machines with unusual disk layouts first, then production in batches small enough for one reviewer to read the whole plan.

Before planning, Terraform reads the current settings of every object it manages, and skipping that with -refresh=false can leave the plan wrong. A refresh-only plan proposes state updates for changes made outside Terraform without touching the objects, and applying it records them in state29. Arguments the configuration sets are planned back to their configured values unless ignore_changes names them as managed by another process30. An emergency change therefore ends either in a refresh-only apply and a matching code change, or in a normal apply that reverts it.

vSphere Foundation has no Configuration Drift Management from VCF Operations6. A scheduled plan with -detailed-exitcode against every state, with exit code 2 and no pending change treated as a drift alert, covers the arguments the configuration sets. For clusters that use vSphere Configuration Profiles, the compliance check covers host settings10. PowerCLI reports under the read-only identity cover objects outside both.

Checklist and hold criteria for the first production apply

Our recommendation is to treat the first production apply as a gate. Each item names a role and the evidence that closes it.

  • Ownership table. The platform architect fills in a writer, an identity and a state for every object class, the Supervisor and cluster host configuration included. Evidence: the signed-off table.
  • Pipeline privileges. The vCenter administrator builds each pipeline’s role from lab Privilege Recorder runs of a create, a change and a destroy25. Evidence: the recorded privilege list and the CSV export of the account’s permissions26.
  • Runner trust. The pipeline owner installs VCF.PowerCLI 9.1.1 on PowerShell 7.6 and imports vCenter’s root certificates as KB 330833 describes. Evidence: a connection with InvalidCertificateAction at Fail and a provider block with allow_unverified_ssl at false420.
  • Interoperability. The platform architect looks up VCF PowerCLI 9.1.1 with vCenter 9.1.1 in the Broadcom interoperability matrix18. Evidence: the saved result.
  • State. The pipeline owner moves state to a backend that locks and encrypts at rest, and commits .terraform.lock.hcl22232728. Evidence: a second concurrent plan that is refused the lock, and the backend’s encryption setting.
  • Approval routing. The change manager signs off the exit-code routing in Figure 2. Evidence: a test plan that destroys a lab object and reaches the second approver.
  • Import pilot. A vSphere engineer imports the lab virtual machines. Evidence: the import plan and the plan after the first apply, both with configuration-level changes only.
  • Drift schedule. Operations turns on the scheduled plan for every state on the day of the first apply. Evidence: an alert from a deliberate out-of-band lab change.

Hold the first production apply, or the next import batch, while any item lacks evidence, when an import plan or the plan after it shows a disk, clone or reboot change, when another run holds the state lock, or when an exit code 2 has no reviewed code change behind it. A finished import batch is a safe place to stop, since the rest keep their current writer. A held batch is retried only with a new plan that shows configuration-level changes only and the recorded cause of the earlier change, such as a disk label out of SCSI order.

Three points stay open. For a Supervisor that Terraform already created, the provider page does not say how to keep or release that resource without a later destroy and recreate. Neither PowerCLI page states the pairing of VCF PowerCLI 9.1.1 with vCenter 9.1.1, hence the matrix check above. And while the vSphere Foundation identity guidance favors tokens where possible, the vsphere provider documents only a user name and password4, and PowerCLI’s SAML2 security context8 still needs a tested way to obtain a token from a vSphere Foundation vCenter. Until they are settled, give every pipeline a password from the CI secret store, an account of its own and a drift plan from its first day, so the first out-of-band change is caught by a pipeline rather than by the next apply.

Sources

Show all 32 sources
  1. vCenter 9.1.1.0100 Release Notes
  2. ESX 9.1.1.0100 Release Notes
  3. VCF PowerCLI
  4. Terraform Provider for VMware vSphere v2.17.1 Documentation
  5. Terraform Provider for VMware vSphere Changelog
  6. VMware Cloud Foundation 9.1 and VMware vSphere Foundation 9.1: Feature Comparison & Upgrade Paths
  7. Bill of Materials 9.1.1
  8. Connect-VIServer Command
  9. vsphere_virtual_machine
  10. What is vSphere Configuration Profiles
  11. vsphere_configuration_profile
  12. vsphere_license
  13. vsphere_host
  14. vsphere_supervisor_v2
  15. vsphere_role
  16. vsphere_entity_permissions
  17. PowerCLI Installation Guide
  18. Compatibility Matrix for VMware Cloud Foundation PowerCLI
  19. PowerShell Support Lifecycle
  20. Set-PowerCLIConfiguration Command
  21. Terraform Provider for VMware vSphere README
  22. Manage sensitive data in your configuration
  23. Dependency Lock File
  24. Best Practices for vCenter Roles and Permissions
  25. Using Privilege Recorder
  26. Export Roles and Permissions from the vSphere Client
  27. Remote State
  28. State Locking
  29. terraform plan command reference
  30. lifecycle block reference
  31. Import resources overview
  32. vsphere_compute_cluster