{"id":6101,"date":"2018-09-28T13:59:59","date_gmt":"2018-09-28T17:59:59","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=6101"},"modified":"2018-09-28T16:40:38","modified_gmt":"2018-09-28T20:40:38","slug":"powershell-calendaring-revisited","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/","title":{"rendered":"PowerShell Calendaring Revisited"},"content":{"rendered":"<p>Early this week, I came across an old snippet of code in my scripts folder, originally published by Lee Holmes. It was an old script, from 2008, on using PowerShell to <a title=\"read the original post\" href=\"http:\/\/www.leeholmes.com\/blog\/2008\/12\/03\/showing-calendars-in-your-oof-messages\/\" target=\"_blank\" rel=\"noopener\">display a calendar with out of office information<\/a>.\u00a0 I seem to recall that I had been trying to do something similar -- display a monthly calendar in the console, when I came across Lee's much better solution. I decided to revive his script and update it. The new version includes a function that displays a calendar in your console.<\/p>\n<p><!--more--><\/p>\n<p>The original script let you specify a begin and end date of months to display. You could also specify days which would be highlighted with asterisks or square brackets.\u00a0 I decided to simplify and only kept the code to highlight certain days with asterisks.\u00a0 I also made the decision to turn the original code, which was a script, into an advanced function. Going to a function, made it easier to use and let me take advantage of advanced function features like parameter sets. Yes, I know you can use many of these features in a script file, but the function makes it all much easier.\u00a0 In fact, now that I think about the code I've written, give a me a few minutes. I'll be right back.<\/p>\n<p>I realized I needed to take the code and turn it into a proper module. It is now published to the PowerShell Gallery.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Install-Module PSCalendar\r\n<\/pre>\n<p>The module should work on PowerShell Core with both Windows and Linux platforms. I don't have a Mac to test.\u00a0 The source code can be found at <a title=\"https:\/\/github.com\/jdhitsolutions\/PSCalendar\" href=\"https:\/\/github.com\/jdhitsolutions\/PSCalendar\">https:\/\/github.com\/jdhitsolutions\/PSCalendar<\/a>, although I'm going to explain a few things here.<\/p>\n<p>The primary command is <a title=\"read the online help\" href=\"https:\/\/github.com\/jdhitsolutions\/PSCalendar\/blob\/master\/docs\/Get-Calendar.md\" target=\"_blank\" rel=\"noopener\">Get-Calendar<\/a>.\u00a0 The default behavior is to display the current month and highlight the current date.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"get-calendar\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar_thumb.png\" alt=\"get-calendar\" width=\"804\" height=\"571\" border=\"0\" \/><\/a><\/p>\n<p>You can also specify a range of months.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar-3.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"get-calendar-3\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar-3_thumb.png\" alt=\"get-calendar-3\" width=\"741\" height=\"772\" border=\"0\" \/><\/a><\/p>\n<p>I wanted to have the ability to specify a month, but I also needed the value to be culture-aware. I didn't want to hard-code a ValidateSet attribute because that would have force me to use US values. I started down the path of using a dynamic param but those are not very user-friendly. So I ended up adding an auto-completer to the module.<\/p>\n<p>PowerShell now includes a command called Register-AutoCompleter. This command allows you to define code that will help you autocomplete a parameter value. You've probably seen that when you type <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113332\" target=\"_blank\" rel=\"noopener\">Get-Service<\/a> followed by a space and then a tab, that PowerShell autocompletes possible values. You can add the same functionality to your code.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Register-ArgumentCompleter -CommandName Get-Calendar, Show-Calendar -ParameterName Month -ScriptBlock {\r\n    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\r\n\r\n    #get month names, filtering out blanks\r\n    (Get-Culture).DateTimeFormat.MonthNames | Where-object {$_ -match \"\\w+\" -and $_ -match \"$WordToComplete\"} |\r\n        ForEach-Object {\r\n        [System.Management.Automation.CompletionResult]::new($_.Trim(), $_.Trim(), 'ParameterValue', $_)\r\n    }\r\n}\r\n<\/pre>\n<p>The code is very similar to what you see when looking at help for Register-AutoCompleter. In my case, I am defining an autocompleter for the commands Get-Calendar and Show-Calendar (more on this one later) that both have a parameter name of Month. The scriptblock is essentially a function that will be executed. As far as I can tell use the parameters with the scriptblock as I have here. There is very little documentation on this command so I'm working from examples . The first part of the scriptblock is getting the culture specific month names. On my computer I was also getting some blanks so I'm filtering to <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113423\" target=\"_blank\" rel=\"noopener\">Where-Object<\/a> to only keep values with word characters. I'm also using the $WordToComplete variable\/parameter. When I run Get-Calendar -Month and begin pressing Tab, PowerShell will start with the first item in the list, January. But if I type \"ju\" and hit tab, PowerShell will jump to \"June\".\u00a0 The \"ju\" becomes the value of $WordToComplete. Each month name is then added as a completion result. The parameters are CompletionText, ListItemText,ResultType (which is a paramter value), and ToolTip.<\/p>\n<p>I do something similar with the -Year parameter to display the current year plus the next 5.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Register-ArgumentCompleter -CommandName Get-Calendar, Show-Calendar -ParameterName Year -ScriptBlock {\r\n    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\r\n\r\n    $first = (Get-Date).Year\r\n    $last = (Get-Date).AddYears(5).Year\r\n    $first..$last |\r\n        ForEach-Object {\r\n        [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\r\n    }\r\n}\r\n<\/pre>\n<p>Here's what it looks like:<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/autocomplete-month.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"autocomplete-month\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/autocomplete-month_thumb.png\" alt=\"autocomplete-month\" width=\"1028\" height=\"573\" border=\"0\" \/><\/a><\/p>\n<p>Currently, there's nothing preventing a user from entering an invalid month. But I'm assuming the autocompleter provides guidance. Still, I will go back at some point and add some additional error handling for an incorrect month.<\/p>\n<p>Oh, and the command also lets you highlight one or more dates.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar-2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"get-calendar-2\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar-2_thumb.png\" alt=\"get-calendar-2\" width=\"1028\" height=\"303\" border=\"0\" \/><\/a><\/p>\n<p>But I love color. So I also wrote a \"wrapper\" function called Show-Calendar that uses the same parameters, but this uses <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113426\" target=\"_blank\" rel=\"noopener\">Write-Host<\/a> to write a colorized version to the console.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/show-calendar.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"show-calendar\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/show-calendar_thumb.png\" alt=\"show-calendar\" width=\"789\" height=\"560\" border=\"0\" \/><\/a><\/p>\n<p>Get-Calendar writes a string to the pipeline.\u00a0 So the challenge I had was turning the string into an array of strings and write each line back using Write-Host. The trickiest part was identifying days marked with asterisks so I could display those days in a highlight color. This required a little regular expression magic.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$cal = Get-Calendar @PSBoundParameters\r\n\r\n    #turn the calendar into an array of strings\r\n    $calarray = $cal.split(\"`n\")\r\n\r\n    # a regular expression pattern to match on highlighted days\r\n    [regex]$m = \"(\\*)?[\\s|\\*]\\d{1,2}(\\*)?\"\r\n    foreach ($line in $calarray) {\r\n\r\n        if ($line -match \"\\d{4}\") {\r\n            write-Host $line -ForegroundColor Yellow\r\n        }\r\n        elseif ($line -match \"\\w{3}|-{3}\") {\r\n            Write-Host $line -ForegroundColor cyan\r\n        }\r\n        elseif ($line -match \"\\*\") {\r\n            #write-host $line -foregroundcolor Magenta\r\n            $week = $line\r\n            $m.Matches($week).Value| foreach-object {\r\n\r\n                $day = \"$_\"\r\n\r\n                if ($day -match \"\\*\") {\r\n                    write-host \"$($day.replace('*','').padleft(3,\" \"))  \" -NoNewline -ForegroundColor $HighlightColor\r\n                }\r\n                else {\r\n                    write-host \"$($day.PadLeft(3,\" \"))  \" -nonewline\r\n                }\r\n            }\r\n            write-host \"\"\r\n        }\r\n        else {\r\n            Write-host $line\r\n        }\r\n    }\r\n<\/pre>\n<p>But now I can use it like this:<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/show-calendar-2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"show-calendar-2\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/show-calendar-2_thumb.png\" alt=\"show-calendar-2\" width=\"1028\" height=\"305\" border=\"0\" \/><\/a><\/p>\n<p>I am using Show-Calendar in my PowerShell profile script along with some other code to highlight important dates coming up.<\/p>\n<p>I hope this shows you that old code can still serve a purpose. Give the module a try and let me know what you think. Use the Github repo to report any issues.<\/p>\n<p>&nbsp;<\/p>\n<p>Enjoy!<\/p>\n<p>&nbsp;<\/p>\n<p>UPDATE: I was concerned that there might be problems with this code in other cultures and that appears to be the case. It is challenging testing and developing with other cultures. But I've filed an issue with myself and will look into it further.<\/p>\n<p>UPDATE #2: I've pushed v1.2.0 to the PowerShell Gallery. I'm basing a number of cultural decisions based on culture values from [system.threading.thread]::CurrentThread.\u00a0 For non-US friends, please let me know how this works for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Early this week, I came across an old snippet of code in my scripts folder, originally published by Lee Holmes. It was an old script, from 2008, on using PowerShell to display a calendar with out of office information.\u00a0 I seem to recall that I had been trying to do something similar &#8212; display a&#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 on the blog: #PowerShell Calendaring Revisited","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":[4,8],"tags":[596,224,534,540],"class_list":["post-6101","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-autocompleter","tag-function","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PowerShell Calendaring Revisited &#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\/6101\/powershell-calendaring-revisited\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell Calendaring Revisited &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Early this week, I came across an old snippet of code in my scripts folder, originally published by Lee Holmes. It was an old script, from 2008, on using PowerShell to display a calendar with out of office information.\u00a0 I seem to recall that I had been trying to do something similar -- display a...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-28T17:59:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-09-28T20:40:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar_thumb.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"PowerShell Calendaring Revisited\",\"datePublished\":\"2018-09-28T17:59:59+00:00\",\"dateModified\":\"2018-09-28T20:40:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/\"},\"wordCount\":922,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/09\\\/get-calendar_thumb.png\",\"keywords\":[\"autocompleter\",\"Function\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/\",\"name\":\"PowerShell Calendaring Revisited &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/09\\\/get-calendar_thumb.png\",\"datePublished\":\"2018-09-28T17:59:59+00:00\",\"dateModified\":\"2018-09-28T20:40:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/09\\\/get-calendar_thumb.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/09\\\/get-calendar_thumb.png\",\"width\":804,\"height\":571},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6101\\\/powershell-calendaring-revisited\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell Calendaring Revisited\"}]},{\"@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":"PowerShell Calendaring Revisited &#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\/6101\/powershell-calendaring-revisited\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell Calendaring Revisited &#8226; The Lonely Administrator","og_description":"Early this week, I came across an old snippet of code in my scripts folder, originally published by Lee Holmes. It was an old script, from 2008, on using PowerShell to display a calendar with out of office information.\u00a0 I seem to recall that I had been trying to do something similar -- display a...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/","og_site_name":"The Lonely Administrator","article_published_time":"2018-09-28T17:59:59+00:00","article_modified_time":"2018-09-28T20:40:38+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar_thumb.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"PowerShell Calendaring Revisited","datePublished":"2018-09-28T17:59:59+00:00","dateModified":"2018-09-28T20:40:38+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/"},"wordCount":922,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar_thumb.png","keywords":["autocompleter","Function","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/","name":"PowerShell Calendaring Revisited &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar_thumb.png","datePublished":"2018-09-28T17:59:59+00:00","dateModified":"2018-09-28T20:40:38+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar_thumb.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/get-calendar_thumb.png","width":804,"height":571},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6101\/powershell-calendaring-revisited\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"PowerShell Calendaring Revisited"}]},{"@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":7212,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7212\/adding-a-powershell-profile-calendar\/","url_meta":{"origin":6101,"position":0},"title":"Adding a PowerShell Profile Calendar","author":"Jeffery Hicks","date":"February 1, 2020","format":false,"excerpt":"Some of you may be aware of my PSCalendar module which you can install from the PowerShell Gallery. The module contains commands that you can use to display a console-based calendar.\u00a0 The calendar commands let you specify days to highlight. These might be days with special events or appointments. I\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\/2020\/02\/image_thumb-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-2.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":3455,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3455\/friday-fun-color-my-web\/","url_meta":{"origin":6101,"position":1},"title":"Friday Fun Color My Web","author":"Jeffery Hicks","date":"September 20, 2013","format":false,"excerpt":"Awhile ago I posted an article demonstrating using Invoke-Webrequest which is part of PowerShell 3.0. I used the page at Manning.com to display the Print and MEAP bestsellers. By the way, thanks to all of you who keep making PowerShell books popular. My original script simply wrote the results to\u2026","rel":"","context":"In &quot;Books&quot;","block_context":{"text":"Books","link":"https:\/\/jdhitsolutions.com\/blog\/category\/books\/"},"img":{"alt_text":"get-manningbestseller1","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-manningbestseller1-1024x606.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-manningbestseller1-1024x606.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-manningbestseller1-1024x606.png?resize=525%2C300 1.5x"},"classes":[]},{"id":3661,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3661\/creating-cim-scripts-without-scripting\/","url_meta":{"origin":6101,"position":2},"title":"Creating CIM Scripts without Scripting","author":"Jeffery Hicks","date":"January 29, 2014","format":false,"excerpt":"When Windows 8 and Windows Server 2012 came out, along with PowerShell 3.0, we got our hands on some terrific technology in the form of the CIM cmdlets. Actually, we got much more than people realize. One of the reasons there was a big bump in the number of shipping\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":1185,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1185\/friday-fun-get-messagebox\/","url_meta":{"origin":6101,"position":3},"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":1061,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1061\/we-pause-a-moment\/","url_meta":{"origin":6101,"position":4},"title":"We Pause a Moment","author":"Jeffery Hicks","date":"January 17, 2011","format":false,"excerpt":"Most of the time when running a PowerShell script or series of commands you want to blast your way through. But there might be times where you want to pause script execution. Perhaps to display an informational message or to simply pace execution. In my work as a trainer and\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\/2011\/01\/pause-example-1024x517.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/01\/pause-example-1024x517.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/01\/pause-example-1024x517.png?resize=525%2C300 1.5x"},"classes":[]},{"id":6388,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6388\/maximizing-my-prompt-in-powershell-core\/","url_meta":{"origin":6101,"position":5},"title":"Maximizing My Prompt in PowerShell Core","author":"Jeffery Hicks","date":"January 10, 2019","format":false,"excerpt":"Yesterday I wrote about my intention to make PowerShell Core, running on Windows 10, my \"daily driver\". I've also written recently about using the PowerShell prompt function to provide a wide range of information. So I decided to combine the two, plus mix in some functionality from my other PowerShell\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\/01\/image_thumb-13.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-13.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-13.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6101","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=6101"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6101\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}