Solved

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

Posted on 2009-04-07
10
786 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

690 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