WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Updating OVF properties for a VM using vSphere API and PowerCLI 

Updating OVF properties for a VM using vSphere API and PowerCLI 

10.31.2017 by William Lam // 5 Comments

Deploying a new OVA/OVF containing OVF properties that need to be configured is super easy using PowerCLI's Get-OvfConfiguration and Import-VApp cmdlets. Many examples can be found online including the PowerCLI Deployment Github repository.

However, once an OVA/OVF has been deployed and running as a standard Virtual Machine, I found there were no out of the box cmdlets for manipulating the OVF properties for a VM as shown in the screenshot below.


Online searches also did not yield any results and hence the opopournity and article 🙂

Just like any VM reconfiguration, you will need to use the vSphere API ReconfigVM_Task() and to update various OVF settings for a VM, you will need to pass in VAppConfigSpec along with a VAppPropertySpec containing the individual OVF property values to update.

To demonstrate the use of this vSphere API, I have created a sample PowerCLI script called VMOvfProperty.ps1 which contains both a Get and Set function.

Here is an example of calling the Get-VMOvfProperty function which simply accepts a VM object (returned by Get-VM) and outputs the OVF property ID, Label, current value and Description as shown in the screenshot below.


If we now want to update some of these OVF properties, we can use the Set-VMOvfProperty which also accepts a VM object along with a hashtable that contains the OVF property IDs and their respective values to update. Below is an example on how to build the PowerShell hashtable based on the output provided above.

$VMNetwork = "sddc-cgw-network-1"
$VMDatastore = "WorkloadDatastore"
$VMNetmask = "255.255.255.0"
$VMGateway = "192.168.1.1"
$VMDNS = "192.168.1.254"
$VMNTP = "50.116.52.97"
$VMPassword = "VMware1!"
$VMDomain = "vmware.local"
$VMIPAddress = "192.168.1.10"
$VMSyslog = "192.168.1.10"

$ovfPropertyChanges = @{
    "guestinfo.syslog"=$VMSyslog
    "guestinfo.domain"=$VMDomain
    "guestinfo.gateway"=$VMGateway
    "guestinfo.ntp"=$VMNTP
    "guestinfo.password"=$VMPassword
    "guestinfo.hostname"=$VMIPAddress
    "guestinfo.dns"=$VMDNS
    "guestinfo.ipaddress"=$VMIPAddress
    "guestinfo.netmask"=$VMNetmask
}

We now simply feed our $ovfPropertyChanges hashtable along with the VM object to our Set-VMOvfProperty function as shown in the screenshot below.


If we now refresh our vSphere Web Client, we can see the OVF properties have been updated with the expected values.


You can also use the Get-VMOvfProperty function to confirm the changes.

More from my site

  • Quick Tip - Retrieving vSAN File Share Network Permissions using vSAN API & PowerCLI
  • Quick Tip - Using PowerCLI to query VMware Tools Configuration at scale 
  • Managing vSAN internet connectivity configuration using the vSAN API
  • Quick Tip - Retrieving NSX segment information from vCenter Server
  • PowerCLI automation for VMware Private AI Foundation with NVIDIA (PAIF-N)

Categories // Automation, PowerCLI, vSphere, vSphere Web Client Tags // ovf, PowerCLI

Comments

  1. *protectedFrank says

    11/03/2017 at 5:09 am

    How do I do something like this to just an ESXi host? All these require a vCenter. What if I need to deploy a VM that is not a vCenter (VCSA) to a standalone host. The VM will be used to deploy the rest of my SDDC stack.

    Reply
    • William Lam says

      11/03/2017 at 6:05 am

      See https://www.williamlam.com/2014/05/how-to-finally-inject-ovf-properties-into-vcsa-when-deploying-directly-onto-esxi.html as ESXi does not support OVF properties natively

      Reply
  2. *protectedFrank says

    11/03/2017 at 12:08 pm

    Thanks, I think i was using --allowextraconfig and --allowallextraconfig after the host told me after it saw the additional properties. I even opened a GSS case and they could not help me. I'll give this a go.

    Reply
  3. *protectedMorgan Yang says

    07/06/2018 at 10:07 am

    Thanks for writing this module, I have found it very helpful. However, I keep on getting an error message with "Wait-Task" on line 70

    Updating OVF Properties ...
    Wait-Task : Operation is not valid due to the current state of the object.
    At /home/morgany/Documents/vmware/powershell/VMOvfProperty.ps1:70 char:14
    + $task1 | Wait-Task
    + ~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Wait-Task], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,VMware.VimAutomation.ViCore.Cmdlets.Commands.WaitTask

    All the VM's were powered off when I run Set-VMOvfProperty, so I'm not sure why the error is occurring.

    What's interesting is when I comment out "Wait-Task", Set-VMOvfProperty seems to run fine. I'm running on VSphere 6.0.0 Update 3

    Reply
  4. *protectedMohsen Pahlevanzadeh says

    02/07/2022 at 5:30 am

    William, How can I do it for local system and file-base?

    Reply

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

  • VMware Flings is now available in Free Downloads of Broadcom Support Portal (BSP) 05/19/2025
  • VMUG Connect 2025 - Minimal VMware Cloud Foundation (VCF) 5.x in a Box  05/15/2025
  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025

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 © 2025

 

Loading Comments...