4.1

Table Of Contents
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 118.
var cmd = new Command("ls -al") ;
cmd.execute(true) ;
System.log(cmd.output) ;
Email Scripting Examples
Workflow scripted elements, actions, and policies require scripting of common email-related tasks. You can
cut, paste, and adapt these examples into your scripted elements.
Obtain an Email Address
The following JavaScript example obtains the email address of the current owner of a running script.
var emailAddress = Server.getRunningUser().emailAddress ;
Send an Email
The following JavaScript example sends an email to the defined recipient, through an SMTP server, with the
defined content.
var message = new EmailMessage() ;
message.smtpHost = "smtpHost" ;
message.subject= "my subject" ;
message.toAddress = "receiver@vmware.com" ;
message.fromAddress = "sender@vmware.com" ;
message.addMimePart("This is a simple message","text/html") ;
message.sendMessage() ;
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 118.
vCenter Orchestrator Developer's Guide
122 VMware, Inc.