Solved

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

Posted on 2009-04-07
10
781 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
Comment Utility


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
Comment Utility
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
Comment Utility
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
 
LVL 14

Accepted Solution

by:
yehudaha earned 500 total points
Comment Utility
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
Comment Utility
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 17

Author Comment

by:Nik
Comment Utility
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
Comment Utility
That's exactly what I needed. Thanks
0
 
LVL 14

Expert Comment

by:yehudaha
Comment Utility
thanks for the grade
0
 
LVL 17

Author Comment

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

Author Comment

by:Nik
Comment Utility
BTW, thank you all who participated in this question.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

744 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