Solved

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

Posted on 2009-04-07
10
785 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

Suggested Solutions

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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 …

730 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