/build/static/layout/Breadcrumb_cap_w.png

Return Scheduled Tasks as a Custom Inventory Rule in KACE

I want to return the Scheduled Tasks on a group of servers with all of the pertenant information into the K1000 as a Custom Inventory Rule so that I can report on which scheduled task runs on what machines and when. Or, if there is a better way to accomplish this, i'm all ears...


0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
I would take a look at SCHTASKS /query from the command prompt. You should be able to tweak the command line for the info you want to return. After you get your command line sorted out you should be able to run something like this in a custom inventory rule. ShellCommandTextReturn(cmd.exe /c schtasks /query /V /FO LIST)
Posted by: dugullett 10 years ago
Red Belt
3

I would take a look at SCHTASKS /query from the command prompt. You should be able to tweak the command line for the info you want to return.

After you get your command line sorted out you should be able to run something like this in a custom inventory rule.

ShellCommandTextReturn(cmd.exe schtasks /query)

Comments:
  • Here is what I've chosen as my command:
    "ShellCommandTextReturn(cmd.exe schtasks /query /V /FO LIST)"

    My problem now is that my machines won't update...I choose force check-in and they don't... - easterdaymatt 10 years ago
    • I'm thinking they are working on checking in, but that command line returns a lot of data. You might want to try taking out the /V. Is Kinventory.exe running when you pull up task manager on one of the machines? - dugullett 10 years ago
      • It is not running. As soon as I disable the rule, the machines start checking in again. Some that have no scheduled tasks come back blank, but those that do never check in. I let them wait it out too and still no go. - easterdaymatt 10 years ago
      • What agent version are you running? - dugullett 10 years ago
      • 5.5.25198 - easterdaymatt 10 years ago
      • Would it be any faster if I ran the command as a script that outputs to text, and then return that text file to the KACE CIF? - easterdaymatt 10 years ago
      • I've had issues with "ShellCommandTextReturn" custom inventory with the 5.5 agents. I've been testing in my test lab and rules that worked in 5.4 no longer work in 5.5.

        Do you have any machines still with the 5.4 agent? If not try downgrading the agent. It's working for me. I did add the /c after cmd.exe.

        ShellCommandTextReturn(cmd.exe /c schtasks /query /FO LIST) - dugullett 10 years ago
      • You could export it to text, but that will still require a "commandtextreturn" command. Which I haven't had luck with in 5.5. I haven't had a lot of time lately to see why. - dugullett 10 years ago
      • Any thoughts as to how I could trim the information? There are some scheduled tasks that are not actually a recurring task, and I don't need those... It's listed as "Next Run Time: Never" - easterdaymatt 10 years ago
      • You can try a custom inventory That will return the info. I just found this script online, and it worked on my machine. I have not tested in a custom inventory rule though. If anything you can export the results to a .txt file and have Kace read it.

        http://www.fixitscripts.com/problems/getting-a-list-of-scheduled-tasks

        $schedule = new-object -com("Schedule.Service")
        $schedule.connect()
        $tasks = $schedule.getfolder("\").gettasks(0)
        $tasks | Format-Table Name , LastRunTime, NextRunTime # -AutoSize
        IF($tasks.count -eq 0) {Write-Host “Schedule is Emptyâ€}
        Read-Host


        Should work?

        ShellCommandTextReturn(powershell $schedule = new-object -com("Schedule.Service")
        $schedule.connect()
        $tasks = $schedule.getfolder("\").gettasks(0)
        $tasks | Format-Table Name , LastRunTime, NextRunTime # -AutoSize
        IF($tasks.count -eq 0) {Write-Host “Schedule is Emptyâ€}
        Read-Host) - dugullett 10 years ago
  • adding the /c fixes the issue. still on 5.5... even with adding the /V - easterdaymatt 10 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ