Solved

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

Posted on 2009-04-07
10
783 Views
Last Modified: 2012-05-06
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
Comment
Question by:Nik
10 Comments
 
LVL 15

Expert Comment

by:markpalinux
ID: 24087284


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
 
LVL 19

Expert Comment

by:jss1199
ID: 24087335
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
 
LVL 14

Expert Comment

by:yehudaha
ID: 24087361
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
Does Powershell have you tied up in knots?

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

 
LVL 14

Accepted Solution

by:
yehudaha earned 500 total points
ID: 24087460
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
 
LVL 38

Expert Comment

by:Shift-3
ID: 24087508
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
 
LVL 17

Author Comment

by:Nik
ID: 24090009
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
 
LVL 17

Author Closing Comment

by:Nik
ID: 31567498
That's exactly what I needed. Thanks
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 24097122
thanks for the grade
0
 
LVL 17

Author Comment

by:Nik
ID: 24097138
I've changed it a bit for our needs, but it was very helpful. Thanks again.
0
 
LVL 17

Author Comment

by:Nik
ID: 24097145
BTW, thank you all who participated in this question.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now