I made two actions, one in JavaScript and the other in PowerShell.
They have the same input: variable name "vm" of type "VC:VirtualMachine"
The PowerShell does not give me any sub-properties. Using dot-notation, it only goes one level down. Code below:
#PowerShell version
function Handler($context, $inputs) {
$inputsString = $inputs | ConvertTo-Json -Compress
$vm = $inputs.vm
Write-Host "VM Name"
Write-Host $vm.Name
Write-Host "VM Guest"
Write-Host $vm.guest
Write-Host "VM Guest Disks"
Write-Host $vm.guest.disks
}
Script Output:
2026-10-01 16:02:03.318 -04:00infoVM Name
2026-10-01 16:02:03.319 -04:00infoC1xClarSQL04P
2026-10-01 16:02:03.320 -04:00infoVM Guest
2026-10-01 16:02:03.321 -04:00info
2026-10-01 16:02:03.322 -04:00infoVM Guest Disks
2026-10-01 16:02:03.323 -04:00info
2026-10-01 16:02:03.324 -04:00infoVM Name
2026-10-01 16:02:03.325 -04:00infoC1xClarSQL04P
2026-10-01 16:02:03.326 -04:00infoVM Guest
2026-10-01 16:02:03.327 -04:00info
2026-10-01 16:02:03.328 -04:00infoVM Guest Disks
2026-10-01 16:02:03.329 -04:00info
//JS version
System.log("VM Name");
System.log(vm.name);
System.log("VM Guest");
System.log(vm.guest);
System.log("VM Guest Disk");
System.log(vm.guest.disk);
Script Output:
2026-10-01 16:03:08.732 -04:00info(com.vmware.tgh/runJScommand) VM Name
2026-10-01 16:03:08.733 -04:00info(com.vmware.tgh/runJScommand) C1xClarSQL04P
2026-10-01 16:03:08.734 -04:00info(com.vmware.tgh/runJScommand) VM Guest
2026-10-01 16:03:08.735 -04:00info(com.vmware.tgh/runJScommand) DynamicWrapper (Instance) : [VcGuestInfo]-[class com.vmware.o11n.plugin.vsphere_gen.GuestInfo_Wrapper] -- VALUE : (vim.vm.GuestInfo) { dynamicType = null, dynamicProperty = null, toolsStatus = toolsOk, toolsVersionStatus = guestToolsCurrent, toolsVersionStatus2 = guestToolsSupportedNew, toolsRunningStatus = guestToolsRunning,
...
2026-10-01 16:03:08.736 -04:00info(com.vmware.tgh/runJScommand) VM Guest Disk
2026-10-01 16:03:08.737 -04:00info(com.vmware.tgh/runJScommand) DynamicWrapper (Instance) : [VcGuestDiskInfo]-[class com.vmware.o11n.plugin.vsphere_gen.DiskInfo_Wrapper] -- VALUE : (vim.vm.DiskInfo) { dynamicType = null, dynamicProperty = null, diskPath = I:\, capacity = 5277637083136, freeSpace = 647008354304, filesystemType = NTFS,
The JavaScript version lets me use dot-notation to go down the whole tree of properties of Object VcVirtualMachine. Even properties that aren't listed in Type VC:VirtualMachine, such as guest, customValue, and tags.
The PowerShell version only lets me go down one level. I have access to all the properties of Type VC:VirtualMachine, but not Object VcVirtualMachine.
It appears that the JavaScript runtime has access to the Object and all its properties. While the PowerShell runtime has access only to the Type and its (limited) properties. Is there a way to get the Object passed to PowerShell runtime? I really need the data from the VcVirtualMachine object combined with the functionality of PowerCLI.