vCO: Find VM name based on UUID


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 Smile

image

image

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);
    }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s