If you want to schedule a PowerCLI/Powershell script (.ps1) using the Windows Task Scheduler, you have to take care of the following requirements:
1. Load the PowerCLI modules
Add the following line at the beginning of your .ps1 script to load the PowerCLI modules:
Get-Module -Name VMware* -ListAvailable | Import-Module
2. Use the following settings when creating the scheduled task
When creating the scheduled task, take care of the following settings in the Action Tab:
Action: „Start a program“
Setting Program/Script: „powershell.exe“
Add arguments (optional): -ExecutionPolicy Bypass C:\Scripts\Test.ps1 (replace Test.ps1 with the name of your script)
You can configure all other settings in the scheduled task as you are used to it. The settings above are the only ones differing from those normally used.