{"id":8357,"date":"2021-04-30T11:39:50","date_gmt":"2021-04-30T15:39:50","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8357"},"modified":"2021-04-30T11:39:55","modified_gmt":"2021-04-30T15:39:55","slug":"friday-fun-counting-down-events-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/","title":{"rendered":"Friday Fun: Counting Down Events with PowerShell"},"content":{"rendered":"\n<div class=\"wp-block-image is-style-default\"><figure class=\"alignleft size-large\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"225\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.png\" alt=\"\" class=\"wp-image-8358\"\/><\/a><\/figure><\/div>\n\n\n\n<p>We just finished  a very successful virtual edition of the PowerShell+DevOps Global Summit. We lost our 2020 event to the pandemic but fortunately, the people at The DevOps Collective were able to pull together a fantastic virtual event. There were as many virtual attendees as we normally have at the in person event. But of course, we are all looking forward to next year when we can gather again in person. Next year's event is April 25-28, 2022 in Bellevue, WA. <\/p>\n\n\n\n<p>There is also an <a href=\"https:\/\/events.devopscollective.org\/event\/automation-devops-summit\/\" target=\"_blank\" rel=\"noreferrer noopener\">Automation + DevOps Summit<\/a> in Nashville this November. So there are things to look forward to. Given that, I thought it would be handy to have a PowerShell tool to help me count down the days. And maybe teach a few things along the way. Let's have some fun.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Timespans<\/h2>\n\n\n\n<p>Creating a timespan between two dates is not that difficult.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">New-TimeSpan -Start (Get-Date) -End ([datetime]\"1\/1\/2022\")<\/code><\/pre>\n\n\n\n<p>The result is a timespan object. Run the code to see for yourself. By the way, you can also simply subtract dates.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">([datetime]\"1\/1\/2022\") - (Get-Date)<\/code><\/pre>\n\n\n\n<p>Finding out how long until the next PowerShell Summit isn't that hard.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/ts-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"754\" height=\"318\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/ts-1.png\" alt=\"\" class=\"wp-image-8359\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/ts-1.png 754w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/ts-1-300x127.png 300w\" sizes=\"auto, (max-width: 754px) 100vw, 754px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a Tool<\/h2>\n\n\n\n<p>This is a good start, but it would be nice to make this easier to use. So I built a small PowerShell function I call Get-EventCountdown. Naturally, it needs a datetime value.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">\u00a0\u00a0Param(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[Parameter(Position=0,Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName,HelpMessage\u00a0=\u00a0\"Enter\u00a0the\u00a0event\u00a0date\u00a0and\u00a0time.\")]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateNotNullOrEmpty()]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateScript({\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if\u00a0($_\u00a0-ge\u00a0(Get-Date))\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$True\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Warning\u00a0\"The\u00a0specified\u00a0events\u00a0date\u00a0has\u00a0already\u00a0occurred.\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Throw\u00a0\"You\u00a0must\u00a0specify\u00a0a\u00a0future\u00a0datetime.\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$false\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0})]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[alias(\"Date\")]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[datetime]$EventDate,<\/code><\/pre>\n\n\n\n<p>I want to be able to take in pipeline input. My plan is to keep a CSV file of upcoming events that I can import and pipe to the function. Notice also the custom [ValidateScript()] attribute. This is something I covered in my presentation at this years's PowerShell Summit.<\/p>\n\n\n\n<p>The scriptblock has to result in a True or False value. If the $EventDate value is greater or equal to now, in other words it has already occurred, then PowerShell will write a warning message and throw a custom exception message. I could also have done this validation in the function if I wanted something a bit less \"noisy\".<\/p>\n\n\n\n<p>Creating the timespan is simple enough.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$ts\u00a0=\u00a0New-Timespan\u00a0-Start\u00a0(Get-Date)\u00a0-End\u00a0$EventDate<\/code><\/pre>\n\n\n\n<p>Now, I could have returned this value and call it good. But why miss an opportunity to write a rich object to the pipeline? My function also takes a parameter for the event name and builds a custom object.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">[PSCustomObject]@{\n\u00a0\u00a0\u00a0\u00a0PSTypename\u00a0=\u00a0\"PSCountdown\"\n\u00a0\u00a0\u00a0\u00a0EventName\u00a0=\u00a0$EventName.Trim()\n\u00a0\u00a0\u00a0\u00a0EventDate\u00a0=\u00a0$EventDate\n\u00a0\u00a0\u00a0\u00a0Countdown\u00a0=\u00a0$ts\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown.png\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"146\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown.png\" alt=\"\" class=\"wp-image-8360\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown.png 786w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-300x56.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-768x143.png 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/a><\/figure>\n\n\n\n<p>The function parameters have aliases to make the command easier to use at the console. They will also work in case the incoming object has a property called \"Date\" and not \"EventDate\". This gives me flexibility. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"253\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2-1024x253.png\" alt=\"\" class=\"wp-image-8361\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2-1024x253.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2-300x74.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2-768x190.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2-1536x379.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2-850x210.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-eventcountdown-2.png 1611w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>The CSV file headings are \"Date\" and \"Name\".<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Leverage Objects<\/h2>\n\n\n\n<p>I could have stopped here, but if you know me, you know that just isn't' going to happen. Because I'm writing a rich object to the pipeline, I want to take advantage of it. In order to do that, you need to make sure your output is a typed object with a unique name and not a generic pscustomobject. That's why my hashtable has a TypeName entry. This becomes my type name.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-type.png\"><img loading=\"lazy\" decoding=\"async\" width=\"856\" height=\"332\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-type.png\" alt=\"\" class=\"wp-image-8362\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-type.png 856w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-type-300x116.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-type-768x298.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-type-850x330.png 850w\" sizes=\"auto, (max-width: 856px) 100vw, 856px\" \/><\/a><\/figure>\n\n\n\n<p>This particular object doesn't have a lot of properties and I don't mind displaying all of them. In other situations, I may be writing a very rich object to the pipeline. That's where custom type and format extensions come into the picture. I'm going to do that here as well.<\/p>\n\n\n\n<p>I used my <a href=\"http:\/\/bit.ly\/31SGo5o\" target=\"_blank\" rel=\"noreferrer noopener\">New-PSFormatXML<\/a> command from the PSScriptTools module to create a custom format file displaying all of the properties in a table by default. In the script file, I add this to load the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Update-Formatdata\u00a0$PSScriptRoot\\pscountdown.format.ps1xml<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Custom Formatting<\/h2>\n\n\n\n<p>Now for the fun part. The Timespan objects include a millisecond component.  PowerShell automatically converts Timeppan objects to strings to display them on the screen. But I don't need to see the milliseconds. In the custom format file, I can create a scriptblock to format the Countdown property.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$cd\u00a0=\u00a0$_.Countdown.ToString(\"dd\\.hh\\:mm\\:ss\")<\/code><\/pre>\n\n\n\n<p>The scriptblock can display this value. In fact, the screen shots above are using this format. But why stop there? Wouldn't something like this be useful?<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format.png\"><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"192\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format.png\" alt=\"\" class=\"wp-image-8363\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format.png 787w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format-300x73.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format-768x187.png 768w\" sizes=\"auto, (max-width: 787px) 100vw, 787px\" \/><\/a><\/figure>\n\n\n\n<p>If an event is imminent, display it in red. If it is getting close, I'll display it in yellow. My format file uses scriptblocks and ANSI escape sequences, assuming you are running in the console host. The coloring doesn't run in VSCode or the PowerShell ISE.<\/p>\n\n\n\n<p>Initially, the format file had hard-coded logic. I was comparing the countdown.totaldays value to 7 and 14. But you might have different ideas of what is imminent and what is pending. Maybe you want to use values of 30 and 45. In the function file, I added 2 variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">#events\u00a0almost\u00a0here\n$PSCountdownCritical\u00a0=\u00a07\n#events\u00a0getting\u00a0closer\n$PSCountdownPending\u00a0=\u00a014<\/code><\/pre>\n\n\n\n<p>When you dot source the script file, these variables are set in your PowerShell session. You can modify the values in the file or after the fact. My format file has code like this to use these variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">If\u00a0($host.name\u00a0-match\u00a0\"console\")\u00a0{\n\u00a0\u00a0\u00a0\u00a0if\u00a0($_.countdown.totaldays\u00a0-le\u00a0$PSCountdownCritical)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"$([char]27)[91m$($_.EventDate)$([char]27)[0m\"\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0elseif\u00a0($_.countdown.totaldays\u00a0-lt\u00a0$PSCountdownPending)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"$([char]27)[93m$($_.EventDate)$([char]27)[0m\"\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0else\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$_.EventDate\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0}\n\u00a0\u00a0else\u00a0{\n\u00a0\u00a0\u00a0$_.EventDate\n\u00a0\u00a0}<\/code><\/pre>\n\n\n\n<p>I didn't want to force people to have to edit the XML file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"221\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format2.png\" alt=\"\" class=\"wp-image-8364\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format2.png 801w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format2-300x83.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/get-pscountdown-format2-768x212.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/a><\/figure>\n\n\n\n<p>You could extend this idea to the ANSI sequences.<\/p>\n\n\n\n<p>In any event, I now have rich PowerShell tool that provides useful information in a meaningful way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Want to Try?<\/h2>\n\n\n\n<p>Want to try this for yourself? The necessary files can be found at <a href=\"https:\/\/gist.github.com\/jdhitsolutions\/17bc013f3ae43c88fd7b14c0f840ad4c\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/gist.github.com\/jdhitsolutions\/17bc013f3ae43c88fd7b14c0f840ad4c<\/a>. Put both files in the same folder and dot source the ps1 file. You can enter values via parameters or from the pipeline.<\/p>\n\n\n\n<p>I'm counting down the days to next year's PowerShell Summit and now you can to. Have a great weekend.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We just finished a very successful virtual edition of the PowerShell+DevOps Global Summit. We lost our 2020 event to the pandemic but fortunately, the people at The DevOps Collective were able to pull together a fantastic virtual event. There were as many virtual attendees as we normally have at the in person event. But of&#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 blo: Friday Fun: Counting Down Events with #PowerShell","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],"tags":[240,224,534,126],"class_list":["post-8357","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-formatting","tag-function","tag-powershell","tag-timespan"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun: Counting Down Events with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here&#039;s how I built a PowerShell tool to help me countdown to important events, like next year&#039;s PowerShell Summit.\" \/>\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\/8357\/friday-fun-counting-down-events-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun: Counting Down Events with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s how I built a PowerShell tool to help me countdown to important events, like next year&#039;s PowerShell Summit.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-30T15:39:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-30T15:39:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun: Counting Down Events with PowerShell\",\"datePublished\":\"2021-04-30T15:39:50+00:00\",\"dateModified\":\"2021-04-30T15:39:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/\"},\"wordCount\":911,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/antique-watch-150x225-1.png\",\"keywords\":[\"formatting\",\"Function\",\"PowerShell\",\"TimeSpan\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/\",\"name\":\"Friday Fun: Counting Down Events with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/antique-watch-150x225-1.png\",\"datePublished\":\"2021-04-30T15:39:50+00:00\",\"dateModified\":\"2021-04-30T15:39:55+00:00\",\"description\":\"Here's how I built a PowerShell tool to help me countdown to important events, like next year's PowerShell Summit.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/antique-watch-150x225-1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/antique-watch-150x225-1.png\",\"width\":150,\"height\":225},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8357\\\/friday-fun-counting-down-events-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun: Counting Down Events with PowerShell\"}]},{\"@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: Counting Down Events with PowerShell &#8226; The Lonely Administrator","description":"Here's how I built a PowerShell tool to help me countdown to important events, like next year's PowerShell Summit.","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\/8357\/friday-fun-counting-down-events-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun: Counting Down Events with PowerShell &#8226; The Lonely Administrator","og_description":"Here's how I built a PowerShell tool to help me countdown to important events, like next year's PowerShell Summit.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2021-04-30T15:39:50+00:00","article_modified_time":"2021-04-30T15:39:55+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun: Counting Down Events with PowerShell","datePublished":"2021-04-30T15:39:50+00:00","dateModified":"2021-04-30T15:39:55+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/"},"wordCount":911,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.png","keywords":["formatting","Function","PowerShell","TimeSpan"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/","name":"Friday Fun: Counting Down Events with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.png","datePublished":"2021-04-30T15:39:50+00:00","dateModified":"2021-04-30T15:39:55+00:00","description":"Here's how I built a PowerShell tool to help me countdown to important events, like next year's PowerShell Summit.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/antique-watch-150x225-1.png","width":150,"height":225},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8357\/friday-fun-counting-down-events-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Friday Fun: Counting Down Events with PowerShell"}]},{"@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":4962,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4962\/powershell-and-devops-summit-2016\/","url_meta":{"origin":8357,"position":0},"title":"PowerShell and DevOps Summit 2016","author":"Jeffery Hicks","date":"April 8, 2016","format":false,"excerpt":"Well another PowerShell Summit has come and gone. Although now we're all grown up and are now the PowerShell and DevOps Global Summit. This year's event was sold out and featured speakers from around the world as well as many people from Microsoft. In fact this is the only event\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4256,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4256\/devops-twitter-chat\/","url_meta":{"origin":8357,"position":1},"title":"DevOps Twitter Chat","author":"Jeffery Hicks","date":"February 24, 2015","format":false,"excerpt":"This Thursday, February 26, I will be doing a live Twitter chat from 12PM to 1PM EST. The topic is DevOps but I'm sure we'll talk about PowerShell and automation in general. Use hashtag #DevOpsChat to submit questions and follow along. You can follow me on Twitter as @JeffHicks. I\u2026","rel":"","context":"In &quot;Pluralsight&quot;","block_context":{"text":"Pluralsight","link":"https:\/\/jdhitsolutions.com\/blog\/category\/pluralsight\/"},"img":{"alt_text":"DevOpsChat-tw_v1_sd","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/02\/DevOpsChat-tw_v1_sd-300x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5541,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5541\/powershelldevops-summit-reflections\/","url_meta":{"origin":8357,"position":2},"title":"PowerShell+DevOps Summit Reflections","author":"Jeffery Hicks","date":"April 17, 2017","format":false,"excerpt":"I've recently returned from Bellevue, WA and the 5th annual PowerShell+DevOps Summit.\u00a0 Each year our event has grown and this year I think we've crossed over into being the PowerShell-related event you should attend. I spoke with many attendees who couldn't stress enough how much they were getting out of\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"summit-logo-1-636x131","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/04\/summit-logo-1-636x131_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/04\/summit-logo-1-636x131_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/04\/summit-logo-1-636x131_thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":5195,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5195\/road-trips\/","url_meta":{"origin":8357,"position":3},"title":"Road Trips","author":"Jeffery Hicks","date":"August 24, 2016","format":false,"excerpt":"It's coming up on that time of year again when I hit the road for series of tech conferences. I try to speak at several so that you have options, assuming you have any interest in what I might be presenting. I realize there is some competition between conferences but\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"http:\/\/csharpcorner.mindcrackerinc.netdna-cdn.com\/UploadFile\/Event\/02042016234636PM\/Ignite.png","src":"https:\/\/i0.wp.com\/csharpcorner.mindcrackerinc.netdna-cdn.com\/UploadFile\/Event\/02042016234636PM\/Ignite.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5547,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5547\/powershell-summit-2017-demo-files\/","url_meta":{"origin":8357,"position":4},"title":"PowerShell Summit 2017 Demo Files","author":"Jeffery Hicks","date":"April 20, 2017","format":false,"excerpt":"During the recent PowerShell+DevOps Global Summit I had two primary presentations, that is, traditional sessions with slides and demos. My other sessions were panels which means if you weren't in the room you missed out on some great content and interaction. Anyway\u2026.my main sessions were on creating class-based PowerShell tools\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"devops-logo","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/04\/devops-logo_thumb.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":8750,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8750\/powershell-plans-for-2022\/","url_meta":{"origin":8357,"position":5},"title":"PowerShell Plans for 2022","author":"Jeffery Hicks","date":"December 27, 2021","format":false,"excerpt":"I'm not much for writing year in review pieces. Nor, to be honest, do I often write New Year's resolutions. But I've been thinking about the work I've done this past year and what I might be doing in 2022 so I thought I'd share some thoughts on what 2022\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"binoculars","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pexels-skitterphoto-63901.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8357","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=8357"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8357\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}