Creating a vSphere scheduled task
In this section, we will discuss ways in which we can create a vSphere scheduled task using the vSphere API through PowerCLI. For this, we will use the ServiceInstance
managed object. This is the singleton root object in the inventory.
Note
For more details, please check the vSphere API documentation at Managed Object Types | ServiceInstance (http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.apiref.doc/vim.ServiceInstance.html).
To create a scheduled task, we will use the CreateScheduledTask
method. If we examine the method, we can see that this method takes two inputs: an entity (MoRef
) and a specification (ScheduledTaskSpec
).
To create a task, we need to create a scheduled task specification. This in turn takes six different inputs:
The rest of the values are static but notice action
and scheduler
. These need to be defined as objects. Note that we defined an Action
, which in turn calls the CreateSnapshot_Task
method to create the snapshot. As the...