{"id":6856,"date":"2023-04-16T23:52:31","date_gmt":"2023-04-16T23:52:31","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=6856"},"modified":"2025-08-01T05:19:56","modified_gmt":"2025-08-01T05:19:56","slug":"how-to-use-a-powershell-script-for-a-monitor-in-labtech-connect-wide","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/how-to-use-a-powershell-script-for-a-monitor-in-labtech-connect-wide","title":{"rendered":"How to use a Powershell script for a Monitor in Labtech Connectwise"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>Create a script that has return 0 when working and return 1 for warning and 2 for failed<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">$events = get-scheduledtask | where {$_.State -ne \"Disabled\"} | where {((Get-ScheduledTaskInfo $_).LastTaskResult -ne \"0\") -and ((Get-ScheduledTaskInfo $_).LastTaskResult -ne \"267009\") -and ((Get-ScheduledTaskInfo $_).LastRunTime -ge ((Get-Date).AddHours(-48)) -and ((Get-ScheduledTaskInfo $_).TaskPath -notlike \"\\Microsoft\\*\" ))} | Select TaskName\n\n$eventcounnt = ($events.TaskName).Count\n\nif ($eventcounnt) {return 1} else {return 0} <\/code><\/pre>\n\n\n\n<p>Copy .ps1 file Labtech server C:\\LTShare\\Transfer\\Montitors<\/p>\n\n\n\n<p>Create a External EXE Check with the bat referenced with script in Exectutable<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2023\/04\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"821\" height=\"741\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2023\/04\/image-5.png\" alt=\"\" class=\"wp-image-6865 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2023\/04\/image-5.png 821w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2023\/04\/image-5-300x271.png 300w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2023\/04\/image-5-768x693.png 768w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Create a script that has return 0 when working and return 1 for warning and 2 for failed Copy .ps1 file Labtech server C:\\LTShare\\Transfer\\Montitors Create a External [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6856","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=6856"}],"version-history":[{"count":5,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6856\/revisions"}],"predecessor-version":[{"id":9081,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6856\/revisions\/9081"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=6856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=6856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=6856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}