Created
November 22, 2015 02:54
-
-
Save vmwarecode/3e81d82714c7ad6ced15 to your computer and use it in GitHub Desktop.
Find vSphere VM by Name across all vCenters in vRealize Orchestrator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//action Inputs: | |
// vmName - string | |
// | |
//Return Type: VC:VirtualMachine | |
var found = VcPlugin.getAllVirtualMachines(null, "xpath:name[matches(.,'"+vmName+"')]"); | |
if (found.length > 1) { | |
throw(vmName+" matched more than one Virtual Machine"); | |
} | |
if (found.length == 1) { | |
return found[0]; | |
} | |
throw("Virtual Machine does not exist by name: "+vmName); |
The search is case sensitive, for case insensitive search use getAllVirtualMachines(null, "xpath:matches(name, '(?i)" + vmName + "')");
Thank you sir. just what I needed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The search is case sensitive, for case insensitive search use getAllVirtualMachines(null, "xpath:matches(name, '(?i)" + vmName + "')");