Scheduling the VM clone
The vCenter task scheduler discussed in the Automating tasks with scheduler recipe in Chapter 6, Basic Administrative Tasks, allows the automation of a lot of management tasks. At the same time, it has limitations. For example, it does not allow scheduling virtual machine clones, which may be necessary when a copy of a VM is needed.
In this, and similar situations, administrators can use Windows Task Scheduler to run the PowerShell script with PowerCLI commands.
Getting ready
Before creating and testing the following VM deployment script described, make sure that:
PowerCLI 5.8 or later is installed on the server, where the script will be executed
The user account that will be used has permissions to clone virtual machines
How to do it...
To accomplish the task, we will create the PowerShell script and schedule it in Windows Task Scheduler.
Creating the script
The PowerShell script to clone a VM consists of the following commands:
Define variables used later in this script:
...