{"id":3445,"date":"2013-09-16T10:07:41","date_gmt":"2013-09-16T14:07:41","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3445"},"modified":"2013-09-16T10:07:41","modified_gmt":"2013-09-16T14:07:41","slug":"get-most-recent-powershell-scheduled-job-result","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/","title":{"rendered":"Get Most Recent PowerShell Scheduled Job Result"},"content":{"rendered":"<p>I think I've posted this before, but in any event even if I did, I've tweaked this code a bit. When you create a scheduled job in PowerShell 3.0, by default PowerShell will keep results on disk for the last 32 times the job ran. This can make it a little tricky if you want to check the most recent job. That's where this short script comes into play.<\/p>\n<pre class=\"lang:ps decode:true\">#requires -version 3.0\r\n\r\n#only show results for Enabled jobs\r\nGet-ScheduledJob | where Enabled |\r\nforeach { Get-Job $_.name -newest 1} | \r\nSelect Name,ID,State,\r\n@{Name=\"Start\";Expression={$_.PSBeginTime}},\r\n@{Name=\"End\";Expression={$_.PSEndTime}},\r\n@{Name=\"Run\";Expression={($_.PSEndTime) - ($_.PSBeginTime)}} | \r\nSort End -Descending<\/pre>\n<p>Technically, this is all I really need:<\/p>\n<pre class=\"lang:ps decode:true\">Get-ScheduledJob | where Enabled | foreach { Get-Job $_.name -newest 1}<\/pre>\n<p>The command gets all scheduled jobs (which is all you can do anyway) and then filters them keeping only the enabled jobs. Get-Job has a parameter to retrieve the newest job. But unfortunately, the object from Get-ScheduledJob doesn't have any properties that match with Get-Job. There is an ID property, but they are for two different things. That's why I resort to piping the filtered objects to ForEach-Object where I can invoke Get-Job using the Name property from the scheduled object job.<\/p>\n<p>The script I use goes a bit further and only selects a few properties I'm interested in. I also calculate a run time for each job. I could create a function out of this, but I simply call the script and typically format the results.<br \/>\n<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png\" alt=\"get-scheduledjob-latest2\" width=\"625\" height=\"142\" class=\"aligncenter size-large wp-image-3447\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-300x68.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-624x142.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2.png 1137w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>You may wonder why I didn't simply include the format command in my script. The reason is that if you include formatting directives, like format table, then there is nothing else you can ever do with the output, except save it to a file or print it. Normally I use a list, but perhaps tomorrow I don't. Or perhaps I might want to select or sort. If I format the output I can't do any of those things. My recommendation is to not use any of the format command in your scripts unless you understand the limitation and wish to live with it.<\/p>\n<p>I think the last time I published this I was getting all the scheduled jobs, which seemed kind of silly. But now that I think about it again, perhaps not. Check back tomorrow.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think I&#8217;ve posted this before, but in any event even if I did, I&#8217;ve tweaked this code a bit. When you create a scheduled job in PowerShell 3.0, by default PowerShell will keep results on disk for the last 32 times the job ran. This can make it a little tricky if you want&#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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[359],"tags":[437,534,392],"class_list":["post-3445","post","type-post","status-publish","format-standard","hentry","category-powershell-3-0","tag-get-job","tag-powershell","tag-scheduled-jobs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Most Recent PowerShell Scheduled Job Result &#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\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Most Recent PowerShell Scheduled Job Result &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I think I&#039;ve posted this before, but in any event even if I did, I&#039;ve tweaked this code a bit. When you create a scheduled job in PowerShell 3.0, by default PowerShell will keep results on disk for the last 32 times the job ran. This can make it a little tricky if you want...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-16T14:07:41+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get Most Recent PowerShell Scheduled Job Result\",\"datePublished\":\"2013-09-16T14:07:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/\"},\"wordCount\":353,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/get-scheduledjob-latest2-1024x233.png\",\"keywords\":[\"Get-Job\",\"PowerShell\",\"Scheduled Jobs\"],\"articleSection\":[\"Powershell 3.0\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/\",\"name\":\"Get Most Recent PowerShell Scheduled Job Result &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/get-scheduledjob-latest2-1024x233.png\",\"datePublished\":\"2013-09-16T14:07:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/get-scheduledjob-latest2.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/get-scheduledjob-latest2.png\",\"width\":1137,\"height\":259},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3445\\\/get-most-recent-powershell-scheduled-job-result\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Powershell 3.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-3-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Most Recent PowerShell Scheduled Job Result\"}]},{\"@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":"Get Most Recent PowerShell Scheduled Job Result &#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\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/","og_locale":"en_US","og_type":"article","og_title":"Get Most Recent PowerShell Scheduled Job Result &#8226; The Lonely Administrator","og_description":"I think I've posted this before, but in any event even if I did, I've tweaked this code a bit. When you create a scheduled job in PowerShell 3.0, by default PowerShell will keep results on disk for the last 32 times the job ran. This can make it a little tricky if you want...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-09-16T14:07:41+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get Most Recent PowerShell Scheduled Job Result","datePublished":"2013-09-16T14:07:41+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/"},"wordCount":353,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png","keywords":["Get-Job","PowerShell","Scheduled Jobs"],"articleSection":["Powershell 3.0"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/","name":"Get Most Recent PowerShell Scheduled Job Result &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png","datePublished":"2013-09-16T14:07:41+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2.png","width":1137,"height":259},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Powershell 3.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},{"@type":"ListItem","position":2,"name":"Get Most Recent PowerShell Scheduled Job Result"}]},{"@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":2833,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/","url_meta":{"origin":3445,"position":0},"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":[]},{"id":3449,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3449\/a-better-powershell-get-scheduled-job-results\/","url_meta":{"origin":3445,"position":1},"title":"A Better PowerShell Get Scheduled Job Results","author":"Jeffery Hicks","date":"September 17, 2013","format":false,"excerpt":"Yesterday I posted a quick update on my code to get the most recent scheduled job result in PowerShell. I had been using a simple script. But the more I thought about it, the more I realized I really did need to turn it into a function with more flexibility.\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"get-scheduledjob-latest-ogv","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest-ogv-1024x327.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest-ogv-1024x327.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest-ogv-1024x327.png?resize=525%2C300 1.5x"},"classes":[]},{"id":3648,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3648\/remove-all-but-most-recent-powershell-job\/","url_meta":{"origin":3445,"position":2},"title":"Remove All but Most Recent PowerShell job","author":"Jeffery Hicks","date":"April 21, 2014","format":false,"excerpt":"I like sending little PowerShell tweet tips, but this one is a bit too long for Twitter. Here is a one-liner to remove all but the most recent job result for each job name. get-job | group Name | foreach { $_.group | sort PSEndTime -descending | Select -skip 1\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8564,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8564\/cleaning-up-powershell-jobs\/","url_meta":{"origin":3445,"position":3},"title":"Cleaning Up PowerShell Jobs","author":"Jeffery Hicks","date":"September 17, 2021","format":false,"excerpt":"I am a heavy user of PowerShell jobs. Not only background jobs but also scheduled jobs. They are a critical element in my daily workflow. Every time a job runs, especially scheduled jobs, a job artifact remains which you can see using Get-Job. For scheduled jobs, I try to keep\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\/2021\/09\/remove-job-result.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/09\/remove-job-result.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/09\/remove-job-result.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4471,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4471\/friday-fun-tickle-me-powershell\/","url_meta":{"origin":3445,"position":4},"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":4609,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4609\/historically-speaking\/","url_meta":{"origin":3445,"position":5},"title":"Historically Speaking","author":"Jeffery Hicks","date":"November 24, 2015","format":false,"excerpt":"So I've recently had a need to begin using Slack. I started out using a web browser, but since there is a Windows client I decided to give it a go. This article isn't about Slack as much as what I was curious about and how I decided to tackle\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3445","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=3445"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3445\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}