{"id":2833,"date":"2013-03-05T10:18:21","date_gmt":"2013-03-05T15:18:21","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2833"},"modified":"2014-02-21T08:20:20","modified_gmt":"2014-02-21T13:20:20","slug":"get-scheduled-job-results","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/","title":{"rendered":"Get Scheduled Job Results"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png\" alt=\"talkbubble-v3\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-2345\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png 150w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-198x198.png 198w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a>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 managed with the regular PowerShell job cmdlets. However, you will most likely end up with a large number of job results, unless you configure a smaller execution history. So the challenge is easily finding the most current job result. Here's what I'm talking about.<\/p>\n<p>Right now I have two scheduled jobs on my computer.<\/p>\n<pre class=\"lang:batch decode:true \" >PS Scripts:\\&gt; get-scheduledjob<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-1024x358.png\" alt=\"get-scheduledjob\" width=\"625\" height=\"218\" class=\"aligncenter size-large wp-image-2834\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-1024x358.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-300x105.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-624x218.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob.png 1037w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>When I run this command this will load the PSScheduledJob module. The benefit is that this also loads the ScheduledJob definition so that when I run Get-Job, I'll see the results. Without the module loaded, Get-Job wouldn't show anything.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-results.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-results-1024x358.png\" alt=\"get-scheduledjob-results\" width=\"625\" height=\"218\" class=\"aligncenter size-large wp-image-2835\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-results-1024x358.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-results-300x105.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-results-624x218.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-results.png 1037w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>Right now, there are only a few results for each job. But even so, I'd like an easy way to check the most recent job. This is where you need to read the help. Originally I did not, shame on me, and I ended up with a convoluted solution. But it is actually quite easy.<\/p>\n<pre class=\"lang:batch decode:true \" >PS Scripts:\\&gt; get-job \"Daily Work backup\" -Newest 1<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-latest.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-latest-1024x247.png\" alt=\"get-scheduledjob-latest\" width=\"625\" height=\"150\" class=\"aligncenter size-large wp-image-2837\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-latest-1024x247.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-latest-300x72.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-latest-624x151.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-latest.png 1037w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>I can even display more pertinent details.<\/p>\n<pre class=\"lang:batch decode:true \" >PS Scripts:\\&gt; get-job \"Daily Work backup\" -Newest 1 | Select Name,State,*Time,Location\r\n\r\n\r\nName        : Daily Work Backup\r\nState       : Completed\r\nPSBeginTime : 3\/4\/2013 11:55:05 PM\r\nPSEndTime   : 3\/4\/2013 11:56:37 PM\r\nLocation    : localhost\r\n<\/pre>\n<p>But I have multiple jobs. At first you might try something like this:<\/p>\n<pre class=\"lang:batch decode:true \" >\r\nPS Scripts:\\> get-scheduledjob | get-job -Newest 1 | Select Name,State,*Time,Location\r\n<\/pre>\n<p>But that will fail because Get-Job tries to use the ID property and we need to use the Name property. Again, reading help on the Get-Job parameters would help. Here's a situation where we have to use ForEach-Object.<\/p>\n<pre class=\"lang:batch decode:true \" >\r\nPS Scripts:\\> get-scheduledjob | foreach { get-job -name $_.name -Newest 1} | Select Name,State,*Time,Location\r\n\r\nName        : Daily Work Backup\r\nState       : Completed\r\nPSBeginTime : 3\/4\/2013 11:55:05 PM\r\nPSEndTime   : 3\/4\/2013 11:56:37 PM\r\nLocation    : localhost\r\n\r\nName        : Download PowerShell v3 Help\r\nState       : Completed\r\nPSBeginTime : 3\/5\/2013 6:00:02 AM\r\nPSEndTime   : 3\/5\/2013 6:01:27 AM\r\nLocation    : localhost\r\n<\/pre>\n<p>Excellent. The only extra step I'm going to take is to add a runtime property and rename PSBeginTime and PSEndTime, which is strictly a matter of personal preference.<\/p>\n<pre class=\"lang:ps decode:true \" >#Requires -version 3.0\r\n\r\nGet-ScheduledJob | \r\nforeach { get-job $_.name -newest 1} | \r\nSelect Name,State,\r\n@{Name=\"StartTime\";Expression={$_.PSBeginTime}},\r\n@{Name=\"EndTime\";Expression={$_.PSEndTime}},\r\n@{Name=\"Runtime\";Expression={($_.PSEndTime) - ($_.PSBeginTime)}},\r\nLocation\r\n<\/pre>\n<p>Even though this is only a one line command, because I intend to run it daily I'll stick it in a script file to save some typing.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-script.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-script-1024x500.png\" alt=\"get-scheduledjob-script\" width=\"625\" height=\"305\" class=\"aligncenter size-large wp-image-2838\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-script-1024x500.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-script-300x146.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-script-624x305.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/get-scheduledjob-script.png 1037w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>To make it even easier, I'll define an alias in my profile.<\/p>\n<pre class=\"lang:ps decode:true \" >set-alias -name ljr -value C:\\scripts\\Get-ScheduledJobResult.ps1<\/pre>\n<p>Sure, it took a little time to work out the code in my one-line script. But I only had to type it once and now all I ever need to type is my 3 character alias!<\/p>\n<p>So think about how you can be more efficient and don't forget to read the help!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 managed with the regular PowerShell&#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,8],"tags":[534,392,540],"class_list":["post-2833","post","type-post","status-publish","format-standard","hentry","category-powershell-3-0","category-scripting","tag-powershell","tag-scheduled-jobs","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Scheduled Job Results &#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\/2833\/get-scheduled-job-results\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Scheduled Job Results &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"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 managed with the regular PowerShell...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-05T15:18:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-02-21T13:20:20+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.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\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get Scheduled Job Results\",\"datePublished\":\"2013-03-05T15:18:21+00:00\",\"dateModified\":\"2014-02-21T13:20:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/\"},\"wordCount\":386,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/05\\\/talkbubble-v3-150x150.png\",\"keywords\":[\"PowerShell\",\"Scheduled Jobs\",\"Scripting\"],\"articleSection\":[\"Powershell 3.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/\",\"name\":\"Get Scheduled Job Results &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/05\\\/talkbubble-v3-150x150.png\",\"datePublished\":\"2013-03-05T15:18:21+00:00\",\"dateModified\":\"2014-02-21T13:20:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/05\\\/talkbubble-v3.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/05\\\/talkbubble-v3.png\",\"width\":\"198\",\"height\":\"208\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2833\\\/get-scheduled-job-results\\\/#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 Scheduled Job Results\"}]},{\"@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 Scheduled Job Results &#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\/2833\/get-scheduled-job-results\/","og_locale":"en_US","og_type":"article","og_title":"Get Scheduled Job Results &#8226; The Lonely Administrator","og_description":"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 managed with the regular PowerShell...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-03-05T15:18:21+00:00","article_modified_time":"2014-02-21T13:20:20+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.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\/scripting\/2833\/get-scheduled-job-results\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get Scheduled Job Results","datePublished":"2013-03-05T15:18:21+00:00","dateModified":"2014-02-21T13:20:20+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/"},"wordCount":386,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png","keywords":["PowerShell","Scheduled Jobs","Scripting"],"articleSection":["Powershell 3.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/","name":"Get Scheduled Job Results &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png","datePublished":"2013-03-05T15:18:21+00:00","dateModified":"2014-02-21T13:20:20+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3.png","width":"198","height":"208"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2833\/get-scheduled-job-results\/#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 Scheduled Job Results"}]},{"@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":3449,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3449\/a-better-powershell-get-scheduled-job-results\/","url_meta":{"origin":2833,"position":0},"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":3445,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3445\/get-most-recent-powershell-scheduled-job-result\/","url_meta":{"origin":2833,"position":1},"title":"Get Most Recent PowerShell Scheduled Job Result","author":"Jeffery Hicks","date":"September 16, 2013","format":false,"excerpt":"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\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":"get-scheduledjob-latest2","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-scheduledjob-latest2-1024x233.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2297,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2297\/sql-saturday-129-session-material\/","url_meta":{"origin":2833,"position":2},"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":8564,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8564\/cleaning-up-powershell-jobs\/","url_meta":{"origin":2833,"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":2419,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/2419\/powershell-3-0-scheduled-jobs-slides-and-demos\/","url_meta":{"origin":2833,"position":4},"title":"PowerShell 3.0 Scheduled Jobs Slides and Demos","author":"Jeffery Hicks","date":"June 28, 2012","format":false,"excerpt":"Yesterday I did a webinar for Idera on the new Scheduled Jobs feature of PowerShell 3.0. If you missed it, I believe you can go to http:\/\/www.idera.com\/Events\/RegisterWC.aspx?EventID=404 and view the archived webcast. I'm assuming that once you register you'll be given a link for the webcast. In the meantime, I\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":"","src":"","width":0,"height":0},"classes":[]},{"id":3648,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3648\/remove-all-but-most-recent-powershell-job\/","url_meta":{"origin":2833,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2833","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=2833"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2833\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}