I use this function to register a scheduled job. It runs fine until I disable it, and then re-enable it (Enable-ScheduledJob). They are shown as Enabled in Task Scheduler. What might I be missing here?
(The credential below is the user name and I input the password when registering the job initially. This is also the admin)
[Parameter(Mandatory=$true)] [string] $jobName, [Parameter(Mandatory=$true)] [string] $pathToScript ) $trigger = New-JobTrigger -Daily -At $time $options = New-ScheduledJobOption -RunElevated Register-ScheduledJob -Name $jobName -Trigger $trigger -Credential ".........." -FilePath $pathToScript