My colleague asked me can I find out the VM name based on its UUID. I helped him by running a PowerCLI command: Get-VM | Foreach ($_) {If ((Get-View $_.id).config.uuid -eq “422041b7-8ccd-xxxx-xxxx-2770502e404a“) {Write-host $_.name}}
I was thinking why not build up a vCO workflow so they can help themselves in the future in case they don’t have the PowerCLI installed. Now I turned that good thought into reality
All work done in the script task named ‘Searching UUID or Name’. It allow user to find the name based on UUID, or find the UUID based on the name.
var vms = VcPlugin.getAllVirtualMachines();
vmname = vmname.trim();
vmuuid = vmuuid.trim();
for (i in vms){
var vm = vms[i];
if(vmname==vm.config.name){
System.log(vm.config.name + ” UUID is ” + vm.config.uuid);
}
if(vmuuid==vm.config.uuid){
System.log(vm.config.uuid + ” is the UUID of ” + vm.config.name);
}
}