Then cleaner method is probably to export them to XML
https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/export-scheduledtask?view=windowsserver2022-ps
then import
https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/register-scheduledtask?view=windowsserver2022-ps
--please don't forget to upvote
and Accept as answer
if the reply is helpful--