![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | FWIW - Scheduleded Tasks Here's a script to gather the scheduled task information from a collection of computers: remove-item sch_tasks.csv $headings = '"HostName","TaskName","Next Run Time","Status","Last Run Time","Last Result","Creator","Schedule","Task To Run","Start In","Comment","Scheduled Task State","Scheduled Type","Start Time","Start Date","End Date","Days","Months","Run As User","Delete Task If Not Rescheduled","Stop Task If Runs X Hours and X Mins","Repeat: Every","Repeat: Until: Time","Repeat: Until: Duration","Repeat: Stop If Still Running","Idle Time","Power Management"' ac sch_tasks.csv $headings foreach ($computer in $computers){ $task_query = schtasks /query /fo csv /v /s $computer if ($task_query.count -ge 2){ for ($i=1;$i -le $task_query.count;$i++){ if ($task_query[$i] -notmatch "$headings"){ ac sch_tasks.csv $task_query[$i] } } $tasks_found = import-csv sch_tasks.csv $tasks_found |% { $out_file = $_.hostname + "+" + $_.taskname + ".clixml" export-clixml -path $out_file -inputobject $_} } } It uses the schtasks command to get the task information, and creates PS objects for each task, with the properties named as returned by the command. Some of them have embedded spaces, so they need to be enclosed in quotes eg $task."next run time" Gathering all the task information can be an expensive proposition, so the collected information is saved both as a .csv file and clixml files for each task. The clixml files are name as hostname + taskname.clixml. The can be retrieved individually as objects by doing an import-clixml on the file. Right now, it basically just good for reporting. It wouldn't be too hard to be able to have Run, End, and Delete functions since these only require the host name and task name as parameters. Not sure right now if I want to implement those as script functions or object methods. Changing the properties of the objects and sending that back through schtasks to update the scheduled tasks is going to be more complicated. I'm thinking I may want to alias some of those properties to something a little "friendlier", too. Thoughts/comments welcome. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: FWIW - Scheduleded Tasks On Aug 31, 12:10 pm, Rob Campbell <RobCampb...@xxxxxx> wrote: Quote: > Here's a script to gather the scheduled task information from a collection of > computers: > > remove-item sch_tasks.csv > > $headings = '"HostName","TaskName","Next Run Time","Status","Last Run > Time","Last Result","Creator","Schedule","Task To Run","Start > In","Comment","Scheduled Task State","Scheduled Type","Start Time","Start > Date","End Date","Days","Months","Run As User","Delete Task If Not > Rescheduled","Stop Task If Runs X Hours and X Mins","Repeat: Every","Repeat: > Until: Time","Repeat: Until: Duration","Repeat: Stop If Still Running","Idle > Time","Power Management"' > > ac sch_tasks.csv $headings > > foreach ($computer in $computers){ > $task_query = schtasks /query /fo csv /v /s $computer > > if ($task_query.count -ge 2){ > for ($i=1;$i -le $task_query.count;$i++){ > if ($task_query[$i] -notmatch "$headings"){ > ac sch_tasks.csv $task_query[$i] > } > } > > $tasks_found = import-csv sch_tasks.csv > > $tasks_found |% { > $out_file = $_.hostname + "+" + $_.taskname + ".clixml" > export-clixml -path $out_file -inputobject $_} > > } > } > > It uses the schtasks command to get the task information, and creates PS > objects for each task, with the properties named as returned by the command. > > Some of them have embedded spaces, so they need to be enclosed in quotes > > eg $task."next run time" > > Gathering all the task information can be an expensive proposition, so the > collected information is saved both as a .csv file and clixml files for each > task. The clixml files are name as hostname + taskname.clixml. The can be > retrieved individually as objects by doing an import-clixml on the file. > > Right now, it basically just good for reporting. > > It wouldn't be too hard to be able to have Run, End, and Delete functions > since these only require the host name and task name as parameters. Not sure > right now if I want to implement those as script functions or object methods. > > Changing the properties of the objects and sending that back through > schtasks to update the scheduled tasks is going to be more complicated. > > I'm thinking I may want to alias some of those properties to something a > little "friendlier", too. > > Thoughts/comments welcome. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| WLM Tasks | Live Mail | |||
| Tasks | Vista mail | |||
| Why do i get tasks that i know nothing about?? | VB Script | |||
| Drowning in Tasks - Help? | Vista General | |||
| ReadyBoost? ... just a FWIW | Vista General | |||