You can export it as a Javascript instead of Powershell. Can you try and see if it solves your problem?
------------------------------
If you find the answer helpful, please click on the RECOMMEND button.
Please visit my blog to get more information:
https://www.clouddepth.com------------------------------
Original Message:
Sent: Feb 12, 2025 01:21 AM
From: kuku Forever
Subject: create a new Scheduled Tasks from VRO to my VC
hi
I need to create a Scheduled Tasks from VRO to my VC
this is the example record from my VC
I need to know how to start to build the in on Scriptable task ?
#---------------CreateScheduledTask---------------
$entity = New-Object VMware.Vim.ManagedObjectReference
$entity.Type = 'VirtualMachine'
$entity.Value = 'vm-2258822'
$spec = New-Object VMware.Vim.ScheduledTaskSpec
$spec.Scheduler = New-Object VMware.Vim.OnceTaskScheduler
$spec.Scheduler.RunAt = [System.DateTime]::Parse('02/11/2025 09:39:00')
$spec.Notification = ''
$spec.Name = 'MYVMTest001 - Delete Snapshots'
$spec.Action = New-Object VMware.Vim.MethodAction
$spec.Action.Argument = New-Object VMware.Vim.MethodActionArgument[] (2)
$spec.Action.Argument[0] = New-Object VMware.Vim.MethodActionArgument
$spec.Action.Argument[1] = New-Object VMware.Vim.MethodActionArgument
$spec.Action.Argument[1].Value = New-Object VMware.Vim.SnapshotSelectionSpec
$spec.Action.Argument[1].Value.RetentionDays = 3
$spec.Action.Name = RemoveAllSnapshots_Task
$spec.Description = 'des kuku'
$spec.Enabled = $true
$_this = Get-View -Id 'ScheduledTaskManager-ScheduledTaskManager'
$_this.CreateScheduledTask($entity, $spec)