Ad Widget

Collapse

Trying to get windows scheduled task state

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shlomia
    Member
    • Jul 2020
    • 38

    #1

    Trying to get windows scheduled task state

    Hi, I've just started using the following template to monitor my windows scheduled tasks:
    https://share.zabbix.com/operating-s...hes-planifiees

    So it works perfect but the only problem is it doesn't pull the scheduled task state ( Disabled or Enabled ).
    Now, I tried to edit the powershell script my self and added the following lines:
    Code:
    switch ($ITEM) {
    "TaskStatus" {
    [string] $name = $ID
    $name1 = $name.replace('â','â').replace('à','à ').replace('ç','ç').replace('é','é') .replace('è','è').replace('ê','ê')
    $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1"
    $pathtask1 = $pathtask.Taskpath
    $taskResult = Get-ScheduledTask -TaskPath "$pathtask1" -TaskName "$name1" | Select State
    Write-Output ($taskResult.Status)
    But it doesn't seem to work, I get the error below when I try to execute the item:
    Value of type "string" is not suitable for value type "Numeric (unsigned)". Value ""

    I get empty value for some reason, Anyone here can help me please? :P

    Thank you!
  • shlomia
    Member
    • Jul 2020
    • 38

    #2
    Found the solution here:
    GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

    Comment

    Working...