VMware vSphere: Pass variables from vCenter into a virtual machine

Hi,

this post describes on how to to pass data, for example a variable, from vCenter into a virtual machine.

If VMware tools are installed you can read all “guestinfo.*” variables within the virtual machine.

Get with Powercli all guestInfo variables set at the virtual machine:

PS D:\> get-vm MyVM | Get-AdvancedSetting guestinfo.* | ft -AutoSize

Name                                  Value
----                                  -----
guestInfo.detailed.data               architecture='X86' bitness='64' buildNumber='22631' distroName='Windows' d
guestinfo.Cb.InstallStatus            3013
guestinfo.Cb.LauncherVersion          1.3.1
guestinfo.driver.vmci.version         9.8.18.0
guestinfo.driver.vsock.version        9.8.22.0
guestinfo.driver.wddm.version         9.17.08.0009
guestinfo.vmtools.buildNumber         24276846
guestinfo.vmtools.description         VMware Tools 12.5.0 build 24276846
guestinfo.vmtools.versionNumber       12448
guestinfo.vmtools.versionString       12.5.0
guestinfo.vmware.components.available salt_minion
guestinfo.appInfo                     {... 

Then logon to your VMware and try to read those variables. You can use vmtoolsd.exe or rpctool.exe

D:\> "C:\Program Files\VMware\VMware Tools\vmtoolsd.exe" config --cmd "info-get guestinfo.appinfo"
D:\> "C:\Program Files\VMware\VMware Tools\rpctool.exe" "info-get guestinfo.appinfo"
{
"version":"1",
"updateCounter":"21",
"publishTime":"2024-12-10T13:35:26.661Z",
"applications":[
{"a":"[System Process]","v":""},
{"a":"MsMpEng.exe","v":"4.18.24090.11"},
{"a":"MsSense.exe","v":"10.8775.27682.1012"},
{"a

But how to set your own variable?

PS D:\> get-vm myVM | New-AdvancedSetting -Name guestinfo.myvariable -Value "TEST" -confirm:$false

Or change an existing variable

PS D:\>get-vm myVM |  Get-AdvancedSetting -Name guestinfo.myvariable | Set-AdvancedSetting -Value "TEST" -confirm:$false

And in the VM it looks like

D:\> "C:\Program Files\VMware\VMware Tools\rpctool.exe" "info-get guestinfo.myvariable"
TEST1

Michael