{"id":4839,"date":"2016-01-29T14:53:38","date_gmt":"2016-01-29T19:53:38","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4839"},"modified":"2016-01-29T14:53:38","modified_gmt":"2016-01-29T19:53:38","slug":"friday-fun-improved-powershell-napping","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/","title":{"rendered":"Friday Fun: Improved PowerShell Napping"},"content":{"rendered":"<p>So I had some fun with my post last week on <a title=\"read the article\" href=\"http:\/\/jdhitsolutions.com\/blog\/powershell\/4830\/friday-fun-a-powershell-nap\/\" target=\"_blank\">taking a nap with PowerShell<\/a>. I got some great feedback on Twitter and a new comments on the blog. My initial effort was a relatively simple PowerShell script which certainly got the job done. But I there were a number of areas where I could expand and improve the script and they would be terrific teaching aids. So I did.<\/p>\n<p>The function is defined in a script you can find in <a href=\"https:\/\/gist.github.com\/jdhitsolutions\" target=\"_blank\" title=\"Check out all my Github work\">Github<\/a>.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/jdhitsolutions\/6b6f6f5038df47d5367e.js\"><\/script><\/p>\n<p>Let's look at some of the changes I made. First off, I turned this into a function complete with comment based help. You'll need to dot source the script file into your PowerShell session or profile script to make the command available.<\/p>\n<p>I made just about every option a parameter and added a few parameter aliases as well. So even though I made the Minutes parameter positional so that you don't need to use the parameter name, you could use \u2013Nap or \u2013Time. You'll notice I also made the wakeup message a parameter.\u00a0 Feel free to set your own default value. Otherwise, you can set a different message at different times.<\/p>\n<p>I also realized that if you are napping, someone might still drop by your desk. So I included an option to display a progress bar using <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113428\" target=\"_blank\">Write-Progress<\/a>. This is a cmdlet that doesn't get the love it should.<\/p>\n<p>I defined an array of messages:<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">#an array of status messages if using a progress bar\r\n$ops = \"I'm solving a PowerShell problem\",\"I'm chasing cmdlets\",\r\n\"Brilliance at work\",\"Re-initializing my pipeline\",\r\n\"Go away\",\"I'm checking eyelid integrity\",\"It can wait...\",\r\n\"Don't you dare!\",\"Spawning a new runspace\",\"I'm multitasking\",\r\n\"Nothing is that important\",\"Unless you have beer for me, go away\",\r\n\"I'm testing the new PSNap provider\",\"I need this\",\r\n\"I'm downloading my new matrix\",\"Resource recyling in progress\",\r\n\"Synaptic synch in progress\",\"Neural network rebooting\",\r\n\"If you can read this you shouldn't be here\",\r\n\"$($env:username) has left the building\"<\/pre>\n<p>The messages will be used as the Status property for Write-Progress. I like using a hashtable of parameters to splat when using Write-Progress.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">$progHash = @{\r\n Activity = \"Ssssshhh...\"\r\n Status = $ops[0]\r\n SecondsRemaining = $remainingSeconds\r\n}<\/pre>\n<p>If I use the Progress bar, it is displayed using the seconds remaining.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">if ($ProgressBar ) {\r\n    Write-Progress @proghash\r\n    #tick down $remainingseconds\r\n    $proghash.SecondsRemaining = $remainingSeconds--\r\n    #pick a new random status if remaining seconds is divisible by 10\r\n    if ($remainingSeconds\/10 -is [int]) {\r\n        $proghash.status = $ops | Get-Random\r\n    }\r\n} #if\r\n<\/pre>\n<p>And every 10 seconds I set the status to another randomly selected message. The result is something like this:<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-23.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-23.png\" alt=\"image\" width=\"644\" height=\"102\" border=\"0\" \/><\/a><\/p>\n<p>The last major change I made per a suggestion was to use the text to speech feature to have a Windows voice \"say\" the wake up message. I added a parameter for you to specify a voice name which in the US will most likely be David or Zira.\u00a0 If you don't know the names, you can specify a bogus value like 'foo' and the function will display the available names. This works because I added a validation script to the Voice parameter.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">[ValidateScript({\r\n #get voices\r\n Add-Type -AssemblyName System.speech\r\n $installed = [System.Speech.Synthesis.SpeechSynthesizer]::new().GetInstalledVoices().voiceinfo.Name\r\n if ($installed -match $_ ) {\r\n    $True\r\n }\r\n else {\r\n    [regex]$rx= \"Microsoft\\s+(?\\w+)\\s+\"\r\n    #build a list of voices assuming the voice name is something like Microsoft David Desktop\r\n    $choices = (($rx.Matches($installed)).foreach({$_.groups[\"name\"].value})) -join \",\"\r\n    Throw \"Can't find an installed voice for $_. Possible values are: $choices\"\r\n }\r\n\r\n})]\r\n[Parameter(ParameterSetName = \"voice\")]\r\n[string]$Voice,\r\n<\/pre>\n<p>This is probably a bit more involved than most validation scripts.\u00a0 The main takeaway is that if you use a validation script it has to return either True or False, or throw an exception as I'm doing here. But it works.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-24.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-24.png\" alt=\"image\" width=\"644\" height=\"104\" border=\"0\" \/><\/a><\/p>\n<p>By adding a voice option I decided the function could either display the message using <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113426\" target=\"_blank\">Write-Host<\/a> or speak it. The chime happens in either event.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">If ($Voice) {\r\n    Add-Type -AssemblyName System.speech\r\n    $speech = New-Object System.Speech.Synthesis.SpeechSynthesizer\r\n    #find the matching voice object\r\n    $selected = [System.Speech.Synthesis.SpeechSynthesizer]::new().GetInstalledVoices().voiceinfo.Name | where {$_ -match $voice}\r\n    $speech.SelectVoice($selected)\r\n    $speech.Rate = $Rate\r\n    $speech.SpeakAsync($message) | Out-Null\r\n    #write a blank line to get a new prompt\r\n    Write-Host \"`n\"\r\n}\r\nelse {\r\n    Write-Host \"`n$Message\" -ForegroundColor Yellow\r\n}<\/pre>\n<p>What this meant was that I had to differentiate the parameters which I did with parameter sets.\u00a0 I specified the default in the cmdletbinding attribute.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">[cmdletbinding(DefaultParameterSetName = \"host\")]\r\n<\/pre>\n<p>Then I needed to specify a parameter set name for each parameter.\u00a0 If you don't specify parameter set name, then the parameter will belong to all sets.\u00a0 Or you can do as I did and be explicit. If you do it properly it should be reflected in the help.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-25.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-25.png\" alt=\"image\" width=\"644\" height=\"281\" border=\"0\" \/><\/a><\/p>\n<p>You can see that there are 2 ways to use this command. I'll let you grab a copy and try out the new additions.<\/p>\n<p>Certainly this isn't a production oriented script but I hope it serves up some interesting examples of different scripting techniques and cmdlets.<\/p>\n<p>As always, comments sincerely welcomed.<\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I had some fun with my post last week on taking a nap with PowerShell. I got some great feedback on Twitter and a new comments on the blog. My initial effort was a relatively simple PowerShell script which certainly got the job done. But I there were a number of areas where I&#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":"New from the blog-> Friday Fun: Improved #PowerShell Napping","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":[271,4,8],"tags":[568,534,540,451,236],"class_list":["post-4839","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","category-scripting","tag-friday-fun","tag-powershell","tag-scripting","tag-speech","tag-write-progress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun: Improved PowerShell Napping &#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\/4839\/friday-fun-improved-powershell-napping\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun: Improved PowerShell Napping &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"So I had some fun with my post last week on taking a nap with PowerShell. I got some great feedback on Twitter and a new comments on the blog. My initial effort was a relatively simple PowerShell script which certainly got the job done. But I there were a number of areas where I...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-29T19:53:38+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-23.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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun: Improved PowerShell Napping\",\"datePublished\":\"2016-01-29T19:53:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/\"},\"wordCount\":581,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-23.png\",\"keywords\":[\"Friday Fun\",\"PowerShell\",\"Scripting\",\"Speech\",\"Write-progress\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/\",\"name\":\"Friday Fun: Improved PowerShell Napping &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-23.png\",\"datePublished\":\"2016-01-29T19:53:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-23.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-23.png\",\"width\":644,\"height\":102},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4839\\\/friday-fun-improved-powershell-napping\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun: Improved PowerShell Napping\"}]},{\"@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":"Friday Fun: Improved PowerShell Napping &#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\/4839\/friday-fun-improved-powershell-napping\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun: Improved PowerShell Napping &#8226; The Lonely Administrator","og_description":"So I had some fun with my post last week on taking a nap with PowerShell. I got some great feedback on Twitter and a new comments on the blog. My initial effort was a relatively simple PowerShell script which certainly got the job done. But I there were a number of areas where I...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/","og_site_name":"The Lonely Administrator","article_published_time":"2016-01-29T19:53:38+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-23.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun: Improved PowerShell Napping","datePublished":"2016-01-29T19:53:38+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/"},"wordCount":581,"commentCount":2,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-23.png","keywords":["Friday Fun","PowerShell","Scripting","Speech","Write-progress"],"articleSection":["Friday Fun","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/","name":"Friday Fun: Improved PowerShell Napping &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-23.png","datePublished":"2016-01-29T19:53:38+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-23.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-23.png","width":644,"height":102},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4839\/friday-fun-improved-powershell-napping\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun: Improved PowerShell Napping"}]},{"@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":2330,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2330\/friday-fun-get-latest-powershell-scripts\/","url_meta":{"origin":4839,"position":0},"title":"Friday Fun: Get Latest PowerShell Scripts","author":"Jeffery Hicks","date":"May 18, 2012","format":false,"excerpt":"Probably like many of you I keep almost all of my scripts in a single location. I'm also usually working on multiple items at the same time. Some times I have difficult remembering the name of a script I might have been working on a few days ago that I\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":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/get-latestscript-300x133.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4923,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/4923\/friday-fun-tweaking-the-powershell-ise\/","url_meta":{"origin":4839,"position":1},"title":"Friday Fun: Tweaking the PowerShell ISE","author":"Jeffery Hicks","date":"February 19, 2016","format":false,"excerpt":"Today's fun is still PowerShell related, but instead of something in the console, we'll have some fun with the PowerShell ISE. One of the things I love about the PowerShell ISE is that you can customize it and extend it.\u00a0 My ISE Scripting Geek project is an example.\u00a0 But today\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-12.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1185,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1185\/friday-fun-get-messagebox\/","url_meta":{"origin":4839,"position":2},"title":"Friday Fun Get MessageBox","author":"Jeffery Hicks","date":"March 4, 2011","format":false,"excerpt":"Today's Friday Fun offers a way for you to graphically interact with your PowerShell scripts and functions without resorting to a lot of complex Winform scripting. I have a function that you can use to display an interactive message box complete with buttons like Yes, No or Cancel. You can\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":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/03\/msgbox.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":826,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/826\/friday-the-13-script-blocks\/","url_meta":{"origin":4839,"position":3},"title":"Friday the 13 Script Blocks","author":"Jeffery Hicks","date":"August 13, 2010","format":false,"excerpt":"In celebration of Friday the 13th and to help ward off any triskaidekaphobia I thought I'd offer up 13 PowerShell scriptblocks. These are scriptblocks that might solve a legitimate business need like finding how long a server has been running to the more mercurial such as how many hours before\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1938,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1938\/friday-fun-a-powershell-console-menu\/","url_meta":{"origin":4839,"position":4},"title":"Friday Fun &#8211; A PowerShell Console Menu","author":"Jeffery Hicks","date":"December 30, 2011","format":false,"excerpt":"When working in PowerShell, and especially when scripting, you might want to give the user a choice of actions. For example, you might develop a configuration script that another admin or technician will run. Perhaps one of the steps is to configure networking depending on their location so you want\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":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/12\/console-menu-300x187.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3990,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/","url_meta":{"origin":4839,"position":5},"title":"Friday Fun: Creating PowerShell Scripts with PowerShell","author":"Jeffery Hicks","date":"September 5, 2014","format":false,"excerpt":"Sometimes PowerShell really does seem like magic. Especially when you can use it to handle complicated or tedious tasks, such as creating a PowerShell script. I know many an IT Pro who want to script but without having to actually write a script. Well, I'm not sure that is realistic,\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"012914_1704_CreatingCIM1.png","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4839","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=4839"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4839\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}