Invalid format of XML file of scheduled task exported by Powershell script

I use the following script to export active scheduled tasks, but when I try to import the XML file again, it failed with error message: “The format of the task is not valid. The following error reported: (1,3):Objs:”
Get-ScheduledTask -TaskPath “" | Where-Object {$.State -eq “Ready”} | ForEach-Object {Export-Clixml -Path "C:\Tasks$($.TaskName).xml” -InputObject $_}
Please comment on how to adjust the above script (command/parameters) to export all active scheduled tasks in XML format, one XML file per task.

Welcome to the forum. :wave:t3:

Before we proceed … When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in 1 <---- Click :point_up_2:t4: :wink:

Of course. You did note save the scheduled task to an XML file you saved the output of a PowerShell command to an XML file.

Here you have some help to read about: