5.5.2
Table Of Contents
- Using VMware vCenter Orchestrator Plug-Ins
- Contents
- Using VMware vCenter Orchestrator Plug-Ins
- Introduction to Orchestrator Plug-Ins
- Configure the Orchestrator Plug-Ins
- Using the vCenter Server Plug-In
- Configuring the vCenter Server Plug-In
- vCenter Server Plug-In Scripting API
- Using the vCenter Server Plug-In Inventory
- Access the vCenter Server Plug-In Workflow Library
- vCenter Server Plug-In Workflow Library
- Batch Workflows
- Cluster and Compute Resource Workflows
- Custom Attributes Workflows
- Datacenter Workflows
- Datastore and Files Workflows
- Datacenter Folder Management Workflows
- Host Folder Management Workflows
- Virtual Machine Folder Management Workflows
- Guest Operation Files Workflows
- Guest Operation Processes Workflows
- Power Host Management Workflows
- Basic Host Management Workflows
- Host Registration Management Workflows
- Networking Workflows
- Distributed Virtual Port Group Workflows
- Distributed Virtual Switch Workflows
- Standard Virtual Switch Workflows
- Resource Pool Workflows
- Storage Workflows
- Storage DRS Workflows
- Basic Virtual Machine Management Workflows
- Clone Workflows
- Linked Clone Workflows
- Linux Customization Clone Workflows
- Tools Clone Workflows
- Windows Customization Clone Workflows
- Device Management Workflows
- Move and Migrate Workflows
- Other Workflows
- Power Management Workflows
- Snapshot Workflows
- VMware Tools Workflows
- Using the Configuration Plug-In
- Using the vCO Library Plug-In
- Using the SQL Plug-In
- Using the SSH Plug-In
- Using the XML Plug-In
- Using the Mail Plug-In
- Using the Net Plug-In
- Using the Enumeration Plug-In
- Using the Workflow Documentation Plug-In
- Using the HTTP-REST Plug-In
- Using the SOAP Plug-In
- Using the AMQP Plug-In
- Using the SNMP Plug-In
- Using the Active Directory Plug-In
- Using the Dynamic Types Plug-In
- Configuring and Using the Multi-Node Plug-In
- Using the PowerShell Plug-In
- Using the PowerShell Plug-In Inventory
- Configuring the PowerShell Plug-In
- Running PowerShell Scripts
- Generating Actions
- Passing Invocation Results Between Actions
- PowerCLI Integration with the PowerShell Plug-In
- Sample Workflows
- Access the PowerShell Plug-In API
- Working with PowerShell Results
- Examples of Scripts for Common PowerShell Tasks
- Troubleshooting
- Index
//Check for errors
if (invResult.invocationState == 'Failed'){
System.error(invResult.getErrors());
} else {
//Get PowerShellRemotePSObject
var psObject = invResult.getResults();
var directories = psObject.getRootObject();
var isList = directories instanceof Array
if ( isList ){
for (idx in directories){
var item = directories[idx];
if ( item.instanceOf('System.IO.FileInfo') ){//Check type of object
System.log( item.getProperty('FullName') );//Extract value from result
}
}
} else {
System.log( directories.getProperty('FullName') );//Extract value from result
}
}
host.closeSession( sess.getSessionId());
Example: Connect with Custom Credentials
You can use JavaScript to connect to a PowerShell host with custom credentials.
var sess;
try {
sess = host.openSessionAs(userName, password);
var invResult = sess.invokeScript('$env:username');
//Check for errors
if (invResult.invocationState == 'Failed'){
System.error(invResult.getErrors());
} else {
//Show result
System.log( invResult.getHostOutput() );
}
} catch (ex){
System.error (ex)
} finally {
if (sess) {
host.closeSession( sess.getSessionId());
}
}
Using VMware vCenter Orchestrator Plug-Ins
126 VMware, Inc.