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 ...

Get Mastering PowerCLI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.