WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Hardware Options
    • Hardware Reviews
    • Lab Deployment Scripts
    • Nested Virtualization
    • Homelab Podcasts
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Quick Tip - Encoding special characters for OVFTool on the command-line

Quick Tip - Encoding special characters for OVFTool on the command-line

12.12.2022 by William Lam // 1 Comment

If you use strong and complex passwords that contain special characters (which you should), it can some times be challenging from an automation perspective on how to properly escape these characters, which can also depend on the scripting or programming language that you are using.

Today I learned about a nice little enhancement in OVFTool 4.4 or later, which makes it easy to handle complex passwords containing special characters by supporting URL encoding for these characters. This is also great for those writing automation scripts and not having to input the password interactively but can now be added to OVFTool command-line string.

As an example, lets take the following password: #/MySuperSecretPassword\# which is valid for ESXi, but is problematic for a few reason. The use of the forward slash (/) character is an issue as that that is a delimiter for the OVFTool connection string and both the back slash (\) and number sign (#) also special characters that will cause parsing errors.

Using this URL encoding reference, we simply encode these special characters into the following:

  • # 👉 %23
  • / 👉 %2F
  • \ 👉 %5C

and we now end up with the following password string: %23%2FMySuperSecretPassword%5C%23

Once we properly encode these special characters, we can now pass our password directly or in-directly through the use of a variable on the command-line to OVFTool:

ovftool "vi://root:#/MySuperSecretPassword\#@192.168.30.120"

More from my site

  • Quick Tip - How to deploy vCenter Server Appliance (VCSA) to legacy CPU without VMX Unrestricted Guest feature?
  • Quick Tip - Easily move or copy VMs between two Free ESXi hosts?
  • Quick Tip - How to deploy OVF/OVA to multiple networks using OVFTool?
  • OVFTool 4.4.1 - Upload OVF/OVA from URL using upcoming "pull" mechanism
  • NSX-T Edge OVF property to automatically join NSX-T Management Plane

Categories // Automation, OVFTool Tags // ovftool

Comments

  1. *protectedLuke Huckaba says

    10/16/2023 at 9:12 am

    You can also do this in powershell:

    $password = "#/MySuperSecretPassword\#"
    Add-Type -AssemblyName System.Web
    $encodedPassword = [System.Web.HttpUtility]::UrlEncode($password)

    Now $encodedPassword is %23%2fMySuperSecretPassword%5c%23

    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

  • Minimal resources for deploying VCF 9.0 in a Lab 06/18/2025
  • Using HTTP with VCF 9.0 Installer for Offline Depot 06/18/2025
  • Crowdsourced Lab Hardware for ESXi 9.0 Dashboard 06/17/2025
  • Automating the vSAN Data Migration Pre-check using vSAN API 06/04/2025
  • VCF 9.0 Hardware Considerations 05/30/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...