1) Script looks ok.
When you see MoRefs being returned it means the ScheduledTasks are created
2) Note that the time you pass to the CreateObjectScheduledTask method is in UTC.
You will have to make sure that you specify a time, when converted to your local time, is in the future.
When the scheduled time is past, the task will not run.
3) You are trying to create a ScheduledTask that already exists with that Name
4) To remove a ScheduledTask, you can do
$si = Get-View ServiceInstance
$scheduledTaskManager = Get-View -Id $si.Content.ScheduledTaskManager
Get-View -Id $scheduledTaskManager.ScheduledTask |
ForEach-Object -Process {
if ($_.Info.Name -eq $taskName)
{
$_.RemoveScheduledTask()
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference