Trouble re-enabling scheduled jobs

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)

function Register-Execution{
[datetime] $time,

    [string] $jobName,

    [string] $pathToScript
$trigger = New-JobTrigger -Daily -At $time
$options = New-ScheduledJobOption -RunElevated 
Register-ScheduledJob  -Name $jobName -Trigger $trigger -Credential ".........." -FilePath $pathToScript


SET j.Enabled = 0
FROM MSDB.dbo.sysjobs j
INNER JOIN MSDB.dbo.syscategories c ON j.category_id = c.category_id
WHERE c.[Name] = ‘Database Maintenance’;

I haven’t profiled it, but I suspect

USE msdb ;

EXEC dbo.sp_update_job
@job_name = N’SomeJob’,
@enabled = 0;

Will be generating the same code, but the builtin procs are usually the way to go.

Thanks. Still haven’t given up on Powershell though, if only to know why it fails here.