{"id":1956,"date":"2012-01-05T10:54:41","date_gmt":"2012-01-05T15:54:41","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1956"},"modified":"2012-01-05T10:54:41","modified_gmt":"2012-01-05T15:54:41","slug":"using-start-job-as-a-scheduled-task","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/","title":{"rendered":"Using Start-Job as a Scheduled Task"},"content":{"rendered":"<p>Here's a technique you might want to use for ad hoc troubleshooting or reporting. Even though it is possible to set up scheduled tasks to run PowerShell commands or scripts, it is cumbersome and time consuming. PowerShell v3 offers a great alternative, but I'll cover that another day. Suppose I want to do something every 15 minutes such as check the status of a service. Instead of going through the effort of creating a scheduled task, I'll create a PowerShell job.<\/p>\n<p>If I setup a job, it will run in my PowerShell session for as long as it needs to run or until I close my PowerShell session. Thus the trick is to keep the job running which easy to accomplish with a simple While loop.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nWhile ($True) {<br \/>\n  #do something<br \/>\n}<br \/>\n<\/code><\/p>\n<p>This will loop indefinitely because True is always True. In an interactive session, I can break out of this using Ctrl+C or insert code to break out if some condition is met.  If I use this loop in my Start-Job command, the command will run indefinitely until the job terminates. I can always kill the job with the Stop-Job cmdlet.  Although I suppose you should be careful with the code you put in the While loop as part of job because if you use Stop-Job, there's no way of knowing what code might be executing at the time. But for my use of this technique I'm keeping it simple and quick.<\/p>\n<p>The other part is the timing interval. This is easily accomplished using the Start-Sleep cmdlet and specifying a value in milliseconds, or more typically, seconds. Depending on your task you could also take advantage of eventing, but that too is a bit complicated to setup and tear down. So, now the main part of my While loop looks like this:<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nWhile ($True) {<br \/>\n  #do something<br \/>\n Start-Sleep -seconds 900<br \/>\n}<br \/>\n<\/code><\/p>\n<p>My code will run every 900 seconds (15 minutes). Here's a longer example that I put in a script.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n$file=\"c:\\work\\mylog.txt\"<br \/>\n#the number of seconds to pause between checks<br \/>\n$seconds=600<br \/>\n#the service to check<br \/>\n$service=\"Spooler\"<br \/>\n#the computer to check<br \/>\n$computer=$env:computername<\/p>\n<p>while ($True) {<br \/>\n    $s=get-service $service -ComputerName $computer<br \/>\n    $t=\"{0} Service {1} on {3} has a status of {2}\" -f (Get-Date), $s.name,$s.status,$computer<br \/>\n    $t | Out-File -FilePath $file -Append<br \/>\n    Start-Sleep -seconds $seconds<br \/>\n}<br \/>\n<\/code><\/p>\n<p>I could have put all of that into a script block and created the job, or I could use the script.<\/p>\n<p><code><br \/>\nPS C:\\> start-job -FilePath C:\\scripts\\PollService.ps1<br \/>\n<\/code><\/p>\n<p>The job will write the service status information to a local text file every 10 minutes.  When I'm done I can simply my PowerShell session or run Stop-Job. Here's where it can really get interesting: how about running this \"scheduled task\" ON a remote computer? There are two approaches. It depends on where you want the job to live.  I could keep the job on my computer:<\/p>\n<p><code><br \/>\nPS C:\\> invoke-command -FilePath C:\\scripts\\PollService.ps1 -ComputerName quark -asjob<br \/>\nPS C:\\> get-job 3 | format-list<\/p>\n<p>HasMoreData   : True<br \/>\nStatusMessage :<br \/>\nLocation      : quark<br \/>\nCommand       : #requires -version 2.0<\/p>\n<p>                $file=\"c:\\work\\mylog.txt\"<br \/>\n                #the number of seconds to pause between checks<br \/>\n                $seconds=600<br \/>\n                #the service to check<br \/>\n                $service=\"Spooler\"<br \/>\n                $computer=$env:computername<\/p>\n<p>                while ($True) {<br \/>\n                $s=get-service $service -ComputerName $computer<br \/>\n                $t=\"{0} Service {1} on {3} has a status of {2}\" -f (Get-Date),<br \/>\n                $s.name,$s.status,$computer<br \/>\n                $t | Out-File -FilePath $file -Append<br \/>\n                Start-Sleep -seconds $seconds<br \/>\n                }<br \/>\nJobStateInfo  : Running<br \/>\nFinished      : System.Threading.ManualResetEvent<br \/>\nInstanceId    : 03a48cd0-f21a-4b7d-9a78-f148ec784ff8<br \/>\nId            : 3<br \/>\nName          : Job3<br \/>\nChildJobs     : {Job4}<br \/>\nOutput        : {}<br \/>\nError         : {}<br \/>\nProgress      : {}<br \/>\nVerbose       : {}<br \/>\nDebug         : {}<br \/>\nWarning       : {}<br \/>\nState         : Running<br \/>\n<\/code><\/p>\n<p>The job object is on my (local) computer, even though the task is running on the remote computer. The other approach is to put the job ON the remote computer. This is a little trickier since I have to get the code I want to run ON the remote computer. I could copy the script over. Or I might try something like this:<\/p>\n<p>First I want to convert my script into a scriptblock by stripping out the comments and inserting a semi colon at the end of each line. Then I can create a scriptblock from this text on the remote computer.<\/p>\n<p><code><br \/>\nPS C:\\> $text=get-content C:\\scripts\\PollService.ps1 | where {$_ -notmatch \"^#\" -AND $_} | foreach {\"$_;\"}<br \/>\n<\/code><\/p>\n<p>I can pass this text as a parameter with invoke-command to setup a job on the remote computer. I recommend using a PSSession in case you want to go back later and stop the job.<\/p>\n<p><code><br \/>\nPS C:\\> $quark=new-pssession -comp quark<br \/>\nPS C:\\> invoke-command -scriptblock {param ($txt) $sb=$executioncontext.invokecommand.newscriptblock($txt) ; Start-job -scriptblock $sb } -session $quark -ArgumentList ($text | out-string)<br \/>\n<\/code><\/p>\n<p>The job is created on the remote session and runs indefinitely.<\/p>\n<p><code><br \/>\nPS C:\\> invoke-command {get-job -State Running} -Session $quark<\/p>\n<p>WARNING: 2 columns do not fit into the display and were removed.<\/p>\n<p>Id              Name            State      HasMoreData     Location<br \/>\n--              ----            -----      -----------     --------<br \/>\n17              Job17           Running    True            localhost<br \/>\nPS C:\\> invoke-command {get-content C:\\work\\mylog.txt} -Session $quark<br \/>\n1\/5\/2012 9:37:41 AM Service Spooler on QUARK has a status of Running<br \/>\n1\/5\/2012 9:38:46 AM Service Spooler on QUARK has a status of Running<br \/>\n1\/5\/2012 10:44:54 AM Service Spooler on QUARK has a status of Running<br \/>\n<\/code><\/p>\n<p>As I mentioned there are probably several ways you could do this. When I am finished I can either terminate the PSSession or stop the remote job.<\/p>\n<p><code><br \/>\nPS C:\\> invoke-command {stop-job -State Running -PassThru} -Session $quark<\/p>\n<p>WARNING: 2 columns do not fit into the display and were removed.<\/p>\n<p>Id              Name            State      HasMoreData     Location<br \/>\n--              ----            -----      -----------     --------<br \/>\n17              Job17           Stopped    False           localhost<br \/>\n<\/code><\/p>\n<p>So the next time you need some scheduled PowerShell, at least on a temporary basis, take a look at Start-Job.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a technique you might want to use for ad hoc troubleshooting or reporting. Even though it is possible to set up scheduled tasks to run PowerShell commands or scripts, it is cumbersome and time consuming. PowerShell v3 offers a great alternative, but I&#8217;ll cover that another day. Suppose I want to do something every&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[75,8],"tags":[122,534,87,333,351],"class_list":["post-1956","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-scripting","tag-invoke-command","tag-powershell","tag-remoting","tag-start-job","tag-tasks"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using Start-Job as a Scheduled Task &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Start-Job as a Scheduled Task &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s a technique you might want to use for ad hoc troubleshooting or reporting. Even though it is possible to set up scheduled tasks to run PowerShell commands or scripts, it is cumbersome and time consuming. PowerShell v3 offers a great alternative, but I&#039;ll cover that another day. Suppose I want to do something every...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2012-01-05T15:54:41+00:00\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Using Start-Job as a Scheduled Task\",\"datePublished\":\"2012-01-05T15:54:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/\"},\"wordCount\":610,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Invoke-Command\",\"PowerShell\",\"remoting\",\"Start-Job\",\"Tasks\"],\"articleSection\":[\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/\",\"name\":\"Using Start-Job as a Scheduled Task &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2012-01-05T15:54:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1956\\\/using-start-job-as-a-scheduled-task\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Start-Job as a Scheduled Task\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Start-Job as a Scheduled Task &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/","og_locale":"en_US","og_type":"article","og_title":"Using Start-Job as a Scheduled Task &#8226; The Lonely Administrator","og_description":"Here's a technique you might want to use for ad hoc troubleshooting or reporting. Even though it is possible to set up scheduled tasks to run PowerShell commands or scripts, it is cumbersome and time consuming. PowerShell v3 offers a great alternative, but I'll cover that another day. Suppose I want to do something every...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/","og_site_name":"The Lonely Administrator","article_published_time":"2012-01-05T15:54:41+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Using Start-Job as a Scheduled Task","datePublished":"2012-01-05T15:54:41+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/"},"wordCount":610,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Invoke-Command","PowerShell","remoting","Start-Job","Tasks"],"articleSection":["PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/","name":"Using Start-Job as a Scheduled Task &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2012-01-05T15:54:41+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1956\/using-start-job-as-a-scheduled-task\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Using Start-Job as a Scheduled Task"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2297,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2297\/sql-saturday-129-session-material\/","url_meta":{"origin":1956,"position":0},"title":"SQL Saturday 129 Session Material","author":"Jeffery Hicks","date":"May 14, 2012","format":false,"excerpt":"I spoke this past weekend at a SQL Saturday event in Rochester, NY. My first SQL Saturday event and it was a lot of fun. A great turnout and some very interested attendees. I did three PowerShell sessions on jobs, scheduled jobs\/tasks and an intro to workflows. The latter talk\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6974,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6974\/watching-the-watcher-with-powershell\/","url_meta":{"origin":1956,"position":1},"title":"Watching the Watcher with PowerShell","author":"Jeffery Hicks","date":"November 14, 2019","format":false,"excerpt":"If you followed along with my recent articles about my PowerShell based backup system, you may recall that I used a PowerShell scheduled job an an event subscriber to monitor for file changes in key folders that I want to back up. I created the scheduled task to run at\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-14.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-14.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-14.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-14.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5884,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5884\/email-reminders-for-powershell-tasks\/","url_meta":{"origin":1956,"position":2},"title":"Email Reminders for PowerShell Tasks","author":"Jeffery Hicks","date":"February 7, 2018","format":false,"excerpt":"I've published a new version of the myTasks module to the PowerShell Gallery and its GitHub repository. The big change is that the current version has a feature to send you a daily email with tasks that are due in the next three days. I've added a command called Enable-EmailReminder\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":4471,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4471\/friday-fun-tickle-me-powershell\/","url_meta":{"origin":1956,"position":3},"title":"Friday Fun: Tickle Me PowerShell!","author":"Jeffery Hicks","date":"July 24, 2015","format":false,"excerpt":"I work at home for myself which means I have to act as my own assistant, reminding me of important events and tasks. And sometimes I need a little help. So why not use PowerShell? In the past I've used and written about using a background job to wait until\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6910,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6910\/creating-a-powershell-backup-system-part-2\/","url_meta":{"origin":1956,"position":4},"title":"Creating a PowerShell Backup System Part 2","author":"Jeffery Hicks","date":"November 8, 2019","format":false,"excerpt":"Yesterday I began a series of articles documenting my PowerShell based backup system. The core of my system is using the System.IO.FileSystemWatcher as a means to track daily file changes so I know what to backup. However there are some challenges. I need to watch several folders, I need to\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"Checking pending files","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-5.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-5.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-5.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/image_thumb-5.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2833,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/","url_meta":{"origin":1956,"position":5},"title":"Get Scheduled Job Results","author":"Jeffery Hicks","date":"March 5, 2013","format":false,"excerpt":"One of my favorite features in PowerShell 3.0 is the ability to run a PowerShell job as a scheduled task. I can easily setup a PowerShell background job to run a script but have it registered as a scheduled task. All you need is PowerShell 3.0. The job results are\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"talkbubble-v3","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1956"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1956\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}