Being a sysadmin often means doing some boring stuff on a daily basis. Well, sure, you can use PowerCLI to save yourself the hassle. It’s a powerful tool that I believe any vSphere admin should master at some point. While PowerCLI provides you the ultimate freedom of IT infrastructure management, there’s still a workaround to automate some tasks even through GUI.
For instance, you need, let’s say, to take a VM snapshot regularly, but you cannot write a script for that purpose yet. You still can automate that process and some other tasks with vCenter Server inbuilt task scheduler. No vCenter? No problems, you can schedule some processes on ESXi! The only thing is that you may be limited to the guest OS inbuilt scheduler capabilities. For more freedom, you need some PowerShell and PowerCLI skills. In today’s article, I look through some tasks that you can automate with vCenter and teach you how to schedule them.
Ok, so, what can I schedule?
Here’s the list of tasks I was able to schedule in vCenter.
|vCenter||Scan for updates||Scans for vCenter available updates. Note that you need vSphere Update Manager for this task|
|Datacenter and Cluster||New Virtual Machine||Creates a new VM in the cluster.|
|Add Host||Adds the host to the specified datacenter or cluster.|
|Scan for updates||Checks the available updates for the specified datacenter or cluster.|
|Host||New Virtual Machine||Creates the VM on the specific host.|
|Scan for updates||Scans the host for available updates. vSphere Update Manager is needed for this task.|
|VM||Power On||Powers on the particular VM.|
|Shut Down Guest OS||Shuts down the VM gracefully. Note that you need VMware Tools for scheduling this task.|
|Restart Guest OS||Reboots the VM. VMware Tools are needed to schedule this task.|
|Power Off||Powers off the particular VM.|
|Suspend||Suspends the VM.|
|Reset||Resets the VM state.|
|Migrate||Migrates a VM to the specified host or datastore. You can also migrate it with vMotion|
|Clone to Virtual Machine||Clones the VM and places it on the specified host or cluster.|
|Edit Resource Settings||Allows changing resources dedicated to the specific VM. You can change CPU and memory shares and limits.|
|Take Snapshot||Captures the VM snapshot.|
|Scan for Updates||Checks for available VM updates. You need vSphere Update Manager for this task.|
How things look in vCenter Server
For vCenter, you can schedule scanning for updates. Well, in my case, that was the only option available in the Schedule a New Task dropdown menu.
For a datacenter and cluster, you can schedule the following tasks: New Virtual Machine, Add Host, and Scan for Updates. Well, that’s exactly what I could schedule. Here’s how the Schedule a New Task dropdown list looked like for these vSphere objects in my case.
For the host, you can schedule New Virtual Machine and Scan for Updates.
How to schedule task with vCenter
Most of the boring stuff you do is often somehow related to the VMs. And, you know, vCenter allows you scheduling a bunch of things for VMs:
- Power On
- Shut Down Guest OS
- Restart Guest OS
- Power Off
- Clone to Virtual Machine
- Edit Resource Settings
- Take Snapshot
- Scan for Updates
First, I want to talk specifically about VM snapshot scheduling.
VM snapshot scheduling
First, select the VM. Navigate to the Monitor tab next and click Tasks & Events. Press Scheduled Tasks and select Take Snapshot… from the Schedule a New Task dropdown menu. In the Scheduled Tasks menu, you can find all the scheduled tasks on the list. Remember to be smart and name the tasks properly so that neither you nor your colleagues have troubles with recognizing what each of them is for.
Now, you can play around with the snapshot scheduling settings. Enter the task name in the self-titled field first. You can also add the task description. The most important settings in the snapshot scheduling process (just as in any other operation scheduling) are in the Change menu. There, you can set when and how often operations are performed. Press OK once you are done with scheduling.
Once the scheduled task works out, you can find it on the History list.
Now, I’m going to talk about those three buttons on the right of the Schedule a New Task dropdown menu. These buttons, as it comes from their signs, allow running, editing, and removing the task. Note that there’s a small thing about the Run button: the task is executed right after you press it irrespective of the schedule.
Scheduling a new VM creation
Now, let’s take a look at how you automate a new VM creation. Select the New Virtual Machine… option from the Schedule a New Task dropdown menu. In the Select a creation type menu, there will be only the Create a new virtual machine option available.
On the whole, scheduling the New Virtual Machine task looks pretty much like if you were just creating a VM. The only difference is that you can make this action repetitive.
You need to edit VM settings first, and then you can move to setting how often and when the task is executed. Well, I believe there’s not much to tell you about VM creation, so I leave all the VM settings by default and jump right to the scheduling procedure. In the Scheduling options menu, you can add the description for the task and set how often and when you need it to be performed.
Once the task scheduled, it is displayed on the Scheduled Tasks list in vCenter.
Being executed, the task is listed in the history and has its status changed to success. Now, you have a new VM!
Today, I provided you with the handy workaround to automate some tasks with vCenter. Sure, you still need some PowerCLI skills for the ultimate freedom of your vSphere environment management. In this article, I described many things you can schedule just using vCenter.