sebskc's Posts

Works now perfectly, thank you!
Thanks LucD unfortunately, receiving  below. Definitely doing something wrong, although I'm lost. Here is full script: ############### # These are the values you should get fro... See more...
Thanks LucD unfortunately, receiving  below. Definitely doing something wrong, although I'm lost. Here is full script: ############### # These are the values you should get from your webform # $vmName = 'servername' $snapTime = Get-Date "10/11/18 23:00" $snapName = 'Test' $snapDescription = 'Scheduled snapshot' $snapMemory = $false $snapQuiesce = $true $emailAddr = 'xxx@xxx.com' ############### $vm = Get-VM -Name $vmName $si = get-view ServiceInstance $scheduledTaskManager = Get-View $si.Content.ScheduledTaskManager $spec = New-Object VMware.Vim.ScheduledTaskSpec $spec.Scheduler = New-Object VMware.Vim.MonthlyByWeekdayTaskScheduler $spec.Scheduler.Offset = [VMware.Vim.WeekOfMonth]::second $spec.Scheduler.Weekday = [VMware.Vim.DayOfWeek]::tuesday $spec.Scheduler.Hour = 6 $spec.Name = "Snapshot",$_.VMname -join ' ' $spec.Description = "Take a snapshot of $($vm.Name)" $spec.Enabled = $true $spec.Notification = $emailAddr $spec.Action = New-Object VMware.Vim.MethodAction $spec.Action.Name = "CreateSnapshot_Task" @($snapName,$snapDescription,$snapMemory,$snapQuiesce) | %{     $arg = New-Object VMware.Vim.MethodActionArgument     $arg.Value = $_     $spec.Action.Argument += $arg } $scheduledTaskManager.CreateObjectScheduledTask($vm.ExtensionData.MoRef, $spec)
Hi LucD, Slightly stuck with one thing, below works perfectly but I wish to change from single task execution to reocurring event, once a month. Doing so, changing "$spec.Scheduler = New-Obje... See more...
Hi LucD, Slightly stuck with one thing, below works perfectly but I wish to change from single task execution to reocurring event, once a month. Doing so, changing "$spec.Scheduler = New-Object VMware.Vim.OnceTaskScheduler" to "$spec.Scheduler = New-Object VMware.Vim.MonthlyByWeekdayTaskScheduler" although, I'm unable to ajdust parameters like offset, day and time. Any hints please? For example, willing to task occur second Tuesday, every 1 month at 6:00am.