Tuesday, March 21, 2017

Setting up vCheck PowerShell health check script in Task Scheduler to automatically run daily

One of the scripts I've used quite a lot over the past few years is the community driven vCheck PowerShell HTML framework script:

http://www.virtu-al.net/vcheck-pluginsheaders/vcheck/

Most if not all of my clients have this script setup to run daily so that reports could be sent to them to either identify potential issues before the start of the day or lingering issues that they may not have been aware about. I highly recommend implementing this in all vSphere environments at some capacity to gain insight into the hosts and vCenter.

One of the most common issues clients tend to face is how to set this script to run automatically in a Windows Task Scheduler so this post serves to demonstrate the way I usually set it up.

Begin by launching Task Scheduler on a server you would like to select to execute this task:

image

Select the folder you would like to create the task in, then right click in the window and select Create New Task...:

image

Enter a name for the task, select Run whether user is logged on or not and enable Run with highest privileges in the General tab:

image

Navigate to the Triggers tab and then click on the New... button:

image

Configure the trigger with the frequency you'd like the task to run:

image

Navigate to the Actions tab and then click on the New... button:

image

Fill in the following fields:

Action: Start a program

Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Add arguments (optional): -ExecutionPolicy Unrestricted -executionpolicy Bypass -file c:\vCheck-vSphere-master\vCheck.ps1

Note the following:

-ExecutionPolicy Unrestricted < this is to allow the script to run even though it is unsigned
-executionpolicy Bypass < this will bypass the prompts that are presented when the modules execute

image

Navigate to the Conditions tab and uncheck all the options:

image

Click on the OK button to save the configuration and enter the credentials of an account that you will be using as a service to run this task as well as connecting to vCenter.

No comments: