5.1

Table Of Contents
Setting and Obtaining Properties from a Hashtable
The following JavaScript example sets properties in a hashtable and obtains the properties from the hashtable.
In the following example, the key is always a String and the value is an object, a number, a Boolean, or a String.
var table = new Properties() ;
table.put("myKey",new Date()) ;
// get the object back
var myDate= table.get("myKey") ;
System.log("Date is : "+myDate) ;
Replace the Contents of a String
The following JavaScript example replaces the content of a String and replaces it with new content.
var str1 = "'hello'" ;
var reg = new RegExp("(')", "g");
var str2 = str1.replace(reg,"\\'") ;
System.log(""+str2) ; // result : \'hello\'
Compare Types
The following JavaScript example checks whether an object matches a given object type.
var path = 'myurl/test';
if(typeof(path, string)){
throw("string");
else {
throw("other");
}
Run a Command in the Orchestrator Server
The following JavaScript example allows you to run a command line on the Orchestrator server. Use the same
credentials as those used to start the server.
NOTE Access to the file system is limited by default. To access the file server from Orchestrator, see “Accessing
the Orchestrator Server File System from JavaScript and Workflows,” on page 123.
var cmd = new Command("ls -al") ;
cmd.execute(true) ;
System.log(cmd.output) ;
File System Scripting Examples
Workflow scripted elements, actions, and policies require scripting of common file system tasks. You can cut,
paste, and adapt these examples into your scripted elements.
NOTE Access to the file system is limited by default. To access the file server from Orchestrator, see “Accessing
the Orchestrator Server File System from JavaScript and Workflows,” on page 123.
Chapter 2 Scripting
VMware, Inc. 127