Hi,
I am creating a scheduled job on a remote machine. I am facing issue with defining trigger. I want that job to be executed at the system startup. For that what I am doing is
$trigger = New-JobTrigger -AtStartup
Register-ScheduledJob -FilePath $TargetforConnectionFile -Trigger $trigger -Name AutoConnect -RunNow -ArgumentList (XXXXXX)
When I run this script I am getting an error
Cannot bind parameter 'Trigger'. Cannot convert value "Microsoft.PowerShell.ScheduledJob.ScheduledJobTrigger" to type "Microsoft.PowerShell.ScheduledJob.ScheduledJobTrigger". Error: "Cannot convert the "Microsoft.PowerShell
.ScheduledJob.ScheduledJobTrigger" value of type "Deserialized.Microsoft.PowerShell.ScheduledJob.ScheduledJobTrigger" to type "Microsoft.PowerShell.ScheduledJob.ScheduledJobTrigger"
Can you please suggest what is the problem with my script. If I write triiger as a hashtable like
Register-ScheduledJob –FilePath \\Srv01\Scripts\Update-Version.ps1 –Trigger @{Frequency=Weekly; At="9:00PM"; DaysOfWeek="Monday"; Interval=2} –ScheduledJobOption @{WakeToRun; StartIfNotIdle; MultipleInstancesPoli
cy="Queue"}
This works perfectly fine.
Can anybody please suggest me how to write AtStartup inside the Register-ScheduledJob itself i.e. as Hashtable?
Thanks & Regards,
Girish