1

I will need to move all the job from old server to new server. May I know is that any way to move all the job in the old server to new server by using the script in 1 shot.

Currently I only know to import the job 1 by one all the job into the server and type the account name and password. For example in this screenshot how can I import all 3 job in one time into new server? because in production server I have more than 1000 job for all the server.

Is that any way like using powershell or bat script?

Sample Image

This is the example I have try and it show me this error message enter image description here

Compo
  • 36,585
  • 5
  • 27
  • 39

1 Answers1

1

This is possible using PowerShell commands Get-ScheduledTask, Export-ScheduledTask, and Register-ScheduledTask to get your tasks and loop through them to export then do the reverse to import. Writing this all out for you is beyond the scope of SO though. You might want to have a look at this site it goes into some detail about how to do this.

CM42
  • 80
  • 7
  • I'm trying to follow this but what I need to specified in -xml since my file format is not xml. You can take a look on screenshot Register-ScheduledTask -xml (Get-Content 'C:\PATH\TO\IMPORTED-FOLDER-PATH\TASK-INPORT-NAME.xml' | Out-String) -TaskName "TASK-IMPORT-NAME" -TaskPath "\TASK-PATH-TASKSCHEDULER\" -User COMPUTER-NAME\USER-NAME –Force – Man Chun Liew Jan 23 '20 at 03:54
  • You need to export it to XML first. There are guidelines in that link. You are going to end up with 1 XML per task. I'm not aware of any way to do all tasks in 1 giant file and just copying the task files is not the correct way to do it. – CM42 Jan 23 '20 at 04:02
  • Maybe my memory is slipping but I thought all Windows Scheduled tasks were stored as XML. They just dont have an xml extension. – Squashman Jan 23 '20 at 04:30
  • Oh sorry, I make mistake in export part. Now already in xml format. – Man Chun Liew Jan 23 '20 at 04:39
  • But after that it show me the error message "No mapping between account names and security IDs was done.". Can taka a look on screenshot 2 – Man Chun Liew Jan 23 '20 at 04:40
  • @Squashman No your memory is correct they (certainly appear) are XML but the "recommended way" to transfer them is export. I have to assume there being an export command that something does not work right in some situations if you just copy them. Otherwise why waste the time to actually create Export-ScheduledTask. – CM42 Jan 23 '20 at 13:49
  • Look here. https://serverfault.com/questions/156795/no-mapping-between-account-names-and-security-ids-was-done-when-importing-sche and here https://stackoverflow.com/questions/7770497/error-when-trying-to-register-a-task-with-task-scheduler-win7 and finally here for some related info https://stackoverflow.com/questions/7770497/error-when-trying-to-register-a-task-with-task-scheduler-win7 – CM42 Jan 23 '20 at 20:54