Hi
I am trying to setup a scheduled task orginally taken from (https://communities.vmware.com/thread/541573), we running ESXi 6.7 U3, the task is being created but the date/time is not being passed through. Any help appreciated
The CSV format is
VMName, Description, Date, Time
The script is
# CSV File Format
# VMName,Description
# VM1,Test1
##########################
$snapMemory = $false
$snapQuiesce = $true
$emailAddr = 'xxx@xxx.com
$fileName = 'C:\Temp\Scripts\snapshot.csv'
###############
Import-Csv -Path $fileName -UseCulture | %{
# Verify the scheduled task name is not already in use
$vm = Get-VM -Name $_.VMName
$si = get-view ServiceInstance
$scheduledTaskManager = Get-View $si.Content.ScheduledTaskManager
$spec = New-Object VMware.Vim.ScheduledTaskSpec
$spec.Name = "Snapshot of",$vm.Name -join ' '
$spec.Description = $_.Description
$spec.Enabled = $true
$spec.Notification = $emailAddr
$spec.Scheduler = New-Object VMware.Vim.OnceTaskScheduler
$spec.Scheduler.runat = $_.Date," ",$_.Time -join ''
$spec.Action = New-Object VMware.Vim.MethodAction
$spec.Action.Name = "CreateSnapshot_Task"
@($spec.Name,$spec.Description,$snapMemory,$snapQuiesce) | %{
$arg = New-Object VMware.Vim.MethodActionArgument
$arg.Value = $_
$spec.Action.Argument += $arg
}
$scheduledTaskManager.CreateObjectScheduledTask($vm.ExtensionData.MoRef, $spec)
}