July 2, 2014 at 2:08 pm #16739
OK this one is driving me nuts.
I have a scheduled task I have exported to an XML file.
I try to import it to another machine using the following code:
$User = "domain\administrator" $XML = get-content 'C:\Folder1\task.xml'| out-string Register-ScheduledTask -TaskName "TASK" -Xml $XML -User $User -Password P@ssw0rd -Force
Register-ScheduledTask : The parameter is incorrect. At line:3 char:1 + Register-ScheduledTask -TaskName "TASK" -Xml $XML -User $User -Password P@ssw ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Register-ScheduledTask], CimExc eption + FullyQualifiedErrorId : HRESULT 0x80070057,Register-ScheduledTask
I'm lost, tried all sorts.
Register-ScheduledTask -Xml (get-content 'C:\Folder1\task.xml'| out-string) -TaskName "TASK" -User $User -Password P@ssw0rd –Force
...returns same result as essentially is same code. But only decent example I could find formats the code like this.
I would very much appreciate any help.
July 2, 2014 at 2:12 pm #16741
Have you tried delimiting the password in quotation marks?
July 2, 2014 at 2:17 pm #16743
Hi Don. Thanks for the speedy response!
I have just tried that, returns same error unfortunately. 11:16 PM here, think I've looked at it for too long now....
July 2, 2014 at 2:21 pm #16744
Richard Siddaway wrote:I've found Scheduled Jobs to be a bit flaky and temperamental.
A scheduled job will become corrupt in a number of circumstances:
– running it using the scheduled task cmdlets – almost always
– running it through the task scheduler before it's run once on a schedule – roughly 25% of the time & I can't tie down the reasons
In PowerShell v4 things are a little better as you have the ability to start the scheduled job through the RunNow parameter for Register-ScheduledJob and Set-ScheduledJob. I'd recommend upgrading to PS 4.0 if you want to use scheduled jobs just for those parameters.
Also once your scheduled job has become corrupt, deleting it and recreating won't work. The name is preserved somewhere – haven't tracked it down yet – and the new definition is immediately flagged as corrupted. You need to give the scheduled job a new name
Read this, gave it a new name and it worked.
November 9, 2016 at 9:50 pm #57289
I know this topic has been dormant for a while, but I came across it as I was having the same issue.
The good news is I'm pretty sure I've tracked down the registry keys that represent the corrupted scheduled task!
Search each for the name of the task you are trying and failing to create.
It did the trick for me!
You must be logged in to reply to this topic.