How to add a powershell script to run as a scheduled task.
Make sure you have the latest version of the PowerCLI before you begin. You can grab a copy from the VMware site.
Launch secpol.msc and edit the batch login service to allow the account you are going to use. In local security console –> User Right Assignment –> Log on as a batch job.
In the run command add the following:
In the argument box add the following.
-PSconsolefile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” “& ‘C:\Scripts\adjustshares.ps1′”
Make sure you have credentials in the script and the account has rights to log into Vcenter.