• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 793
  • Last Modified:

How to export Scheduled Jobs from DC's via VBS or Powershell script

Hello to all,

I need to export all scheduled tasks from our Domain Controllers via VBS or PowerShell Script.
Does anyone had similar need and maybe has finished code to share?

Thanks
0
Nik
Asked:
Nik
1 Solution
 
markpalinuxCommented:


schtasks - maybe helpful

You may read that it depends on how they were scheduled. If they were scheduled with at then the step below will not work, if they were scheduled with task scheduler then it should work.

this page discusses Win32_Win32_ScheduledJob
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0922.mspx

Mark
0
 
jss1199Commented:
Use the below command line and capture the output and paste into a blank XML file.  You can then import and/or modify the XML

schtasks /Query [/S  [/U  [/P []]] /XML /TN
0
 
yehudahaCommented:
try this
Set objShell = CreateObject("WSCript.shell")
strServer = InputBox("enter server name")
strPath = InputBox("path to save csv file. e.g : c:\temp")
strCmd = "cmd /c schtasks /query /S \\" & strServer & " /V /FO CSV >" & Chr(34) & strPath & "\" & strServer & ".csv" & chr(34)
objShell.Run(strCmd,0,True)

Open in new window

0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
yehudahaCommented:
little fix
Set objShell = CreateObject("WSCript.shell")
strServer = InputBox("enter server name")
strPath = InputBox("path to save csv file. e.g : c:\temp")
strCmd = "cmd /c schtasks /query /S \\" & strServer & " /V /FO CSV >" & Chr(34) & strPath & "\" & strServer & ".csv" & chr(34)
objShell.Run strCmd,0,True

Open in new window

0
 
Shift-3Commented:
You can just copy the .job files from \\servername\admin$\tasks.  They can be exported to other machines by copying them to the same location.  Usually only the "Run As" parameter has to be adjusted afterwards.
0
 
NikAuthor Commented:
Thank you all for your kind help.

I will try every suggestion and see which will be the best for my needs.

Basically I need the following:

- Name of the Scheduled Task/s (it's essential that I have a list of all running tasks on the server)
- I need it to get that info from around 20 DC's
- Most important thing is that I get the account name which is used to run the scheduled task.

Output file version is insubstantial. .csv, .xml etc, any will do.

Thx, regards,
Nik
0
 
NikAuthor Commented:
That's exactly what I needed. Thanks
0
 
yehudahaCommented:
thanks for the grade
0
 
NikAuthor Commented:
I've changed it a bit for our needs, but it was very helpful. Thanks again.
0
 
NikAuthor Commented:
BTW, thank you all who participated in this question.
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now