LucD - trying to work it out on my own but need your help again please? I'm not sure why I get this error or if I'm on right track? Thanks in advance for your help
Exception calling "CreateObjectScheduledTask" with "2" argument(s): "A specified parameter was not correct:. The value '0'
for the interval is not in the range 1-1000 for the scheduler."
At Z:\InformationTechnology\PS Scripts\CreateWSUSScheduledTasks.ps1:56 char:1
+ $scheduledTaskManager.CreateObjectScheduledTask($vm.ExtensionData.MoR ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
# CSV File Format
# VMName,Description,Quiesce
# VM1,Test1,n
##########################
# Do we quiesce or not
$QS = $_.Quiesce
if($QS -eq 'y') {
$snapMemory = $true
$snapQuiesce = $true
}else{
$snapMemory = $false
$snapQuiesce = $false
}
# $snaptime = Get-Date "08/17/20 14:30"
$emailAddr = 'cvl-vmwarealerts@helixit.ca'
$fileName = 'Z:\InformationTechnology\PS Scripts\snapshots.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.Scheduler = New-Object VMware.Vim.MonthlyByWeekdayTaskScheduler
$spec.Scheduler.Offset = [VMware.Vim.WeekOfMonth]::second
$spec.Scheduler.Weekday = [VMware.Vim.DayOfWeek]::tuesday
$spec.Scheduler.Hour = 14
$spec.Scheduler.Minute = 45
$spec.Name = "PRE WSUS SNAPSHOT OF",$vm.Name -join ' '
$spec.Description = $_.Description
$spec.Enabled = $true
$spec.Notification = $emailAddr
#$spec.Scheduler = New-Object VMware.Vim.OnceTaskScheduler
#$spec.Scheduler.runat = $_.snaptime
$spec.Action = New-Object VMware.Vim.MethodAction
$spec.Action.Name = "CreateSnapshot_Task"
@($spec.Name,$spec.Description,$QS) | %{
$arg = New-Object VMware.Vim.MethodActionArgument
$arg.Value = $_
$spec.Action.Argument += $arg
}