{"id":2081,"date":"2012-02-10T10:32:29","date_gmt":"2012-02-10T15:32:29","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2081"},"modified":"2014-02-14T12:48:52","modified_gmt":"2014-02-14T17:48:52","slug":"friday-fun-powershell-valentines-day","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/","title":{"rendered":"Friday Fun PowerShell Valentines Day"},"content":{"rendered":"<p>With Valentine's Day just around the corner, I thought I should help you out with your gift giving. Remember those bags of candy with the cute sayings like \"Be Mine\"? Here's how you can create a \"bag\" of them using Windows PowerShell; perfect for that extra geeky significant other. Or maybe you'll just have fun playing with this.<\/p>\n<pre class=\"lang:ps decode:true \" >#change the window title\r\n$host.ui.RawUI.WindowTitle=\"Happy Valentine's Day\"\r\n\r\n#define an array of sentiments\r\n$print=@(\"Be mine\",\"Hey cutie\",\"Be my valentine\",\"I luv u\",\"I$([char]3)U\",\"Love\",\r\n\"Romance\",\"Kiss me\",\"Hug me\",\"My Girl\",\"UR the 1\",\"Love me tender\",\"Luv2Luv\",\r\n\"Hold Me\",\"Sweetie\",\"Honey\",\"HunnyBunny\",\"$([char]3)2$([char]3)\",\"4Ever\",\"XXOOXX\")\r\n\r\n#define the colors to use for the candy\r\n$color=\"Cyan\",\"Magenta\",\"Yellow\",\"White\",\"Red\",\"DarkRed\",\"Green\"\r\n\r\n#enter a number greater than 100 for maximum impact\r\n$count=Read-Host \"How many sweethearts do you want?\"\r\n\r\n#create the candy elements\r\n1..$count | foreach -begin {cls} -process {\r\n Write-Host \"$(get-random $print) \" -foreground (get-random $color) -nonewline \r\n } -end {write-host \"`n\"}\r\n<\/pre>\n<p>The first part of the script changes the console title. Nothing extra special there, in terms of PowerShell. Next, I'm defining an array of strings that will be \"printed\" on the \"candy\". I'm also defining an array of colors that you can use with <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113426\" title=\"get online help\" target=\"_blank\">Write-Host<\/a>. Some colors like Gray hardly seem romantic so I'm limiting my array to the \"pretty\" colors. Finally, the script prompts you for the number of candies to create.<\/p>\n<p>The main part of the script is a <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113300\" title=\"get online help\" target=\"_blank\">Foreach-Object<\/a> expression. I'm using the range operator (..) as a counter. Each number is piped to ForEach, but I'm not doing anything with it. What I am doing though is using other cmdlet parameters that you may not be used to seeing. Most of the time when we use ForEach-Object, the scriptblock is the -Process parameter value, which runs once for every object piped in. But in my script I'm also using the -Begin parameter. This scriptblockk executes once before any pipelined objects are processed. In my script I'm simply clearing the screen. In the process script block I'm using Write-Host to write a random string from the $Print array using a random foreground color from the $color array. I'm also using -NoNewLine because I want to fill the screen, (or bag in keeping with my analogy). If I didn't, I'd get a list. But because I'm not writing a new line, when I've reached the maximum number of candies, the -End scriptblock runs which simply adds the necessary return.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines.png\" target='_blank'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines-300x104.png\" alt=\"\" title=\"valentines\" width=\"450\" height=\"156\" class=\"aligncenter size-medium wp-image-2083\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines-300x104.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines-1024x355.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines.png 1157w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>Download <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines.txt' target='_blank'>Valentines.ps1<\/a><\/p>\n<p>Happy Valentine's Day.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With Valentine&#8217;s Day just around the corner, I thought I should help you out with your gift giving. Remember those bags of candy with the cute sayings like &#8220;Be Mine&#8221;? Here&#8217;s how you can create a &#8220;bag&#8221; of them using Windows PowerShell; perfect for that extra geeky significant other. Or maybe you&#8217;ll just have fun&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,4],"tags":[145,321,534,363,101],"class_list":["post-2081","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-array","tag-foreach-object","tag-powershell","tag-random","tag-write-host"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun PowerShell Valentines Day &#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\/2081\/friday-fun-powershell-valentines-day\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun PowerShell Valentines Day &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"With Valentine&#039;s Day just around the corner, I thought I should help you out with your gift giving. Remember those bags of candy with the cute sayings like &quot;Be Mine&quot;? Here&#039;s how you can create a &quot;bag&quot; of them using Windows PowerShell; perfect for that extra geeky significant other. Or maybe you&#039;ll just have fun...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2012-02-10T15:32:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-02-14T17:48:52+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines-300x104.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun PowerShell Valentines Day\",\"datePublished\":\"2012-02-10T15:32:29+00:00\",\"dateModified\":\"2014-02-14T17:48:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/\"},\"wordCount\":336,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/02\\\/valentines-300x104.png\",\"keywords\":[\"Array\",\"ForEach-object\",\"PowerShell\",\"Random\",\"Write-Host\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/\",\"name\":\"Friday Fun PowerShell Valentines Day &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/02\\\/valentines-300x104.png\",\"datePublished\":\"2012-02-10T15:32:29+00:00\",\"dateModified\":\"2014-02-14T17:48:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/02\\\/valentines.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/02\\\/valentines.png\",\"width\":\"1157\",\"height\":\"402\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2081\\\/friday-fun-powershell-valentines-day\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun PowerShell Valentines Day\"}]},{\"@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 PowerShell Valentines Day &#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\/2081\/friday-fun-powershell-valentines-day\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun PowerShell Valentines Day &#8226; The Lonely Administrator","og_description":"With Valentine's Day just around the corner, I thought I should help you out with your gift giving. Remember those bags of candy with the cute sayings like \"Be Mine\"? Here's how you can create a \"bag\" of them using Windows PowerShell; perfect for that extra geeky significant other. Or maybe you'll just have fun...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/","og_site_name":"The Lonely Administrator","article_published_time":"2012-02-10T15:32:29+00:00","article_modified_time":"2014-02-14T17:48:52+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines-300x104.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun PowerShell Valentines Day","datePublished":"2012-02-10T15:32:29+00:00","dateModified":"2014-02-14T17:48:52+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/"},"wordCount":336,"commentCount":2,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines-300x104.png","keywords":["Array","ForEach-object","PowerShell","Random","Write-Host"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/","name":"Friday Fun PowerShell Valentines Day &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines-300x104.png","datePublished":"2012-02-10T15:32:29+00:00","dateModified":"2014-02-14T17:48:52+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/valentines.png","width":"1157","height":"402"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2081\/friday-fun-powershell-valentines-day\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun PowerShell Valentines Day"}]},{"@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":3692,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3692\/another-powershell-valentine\/","url_meta":{"origin":2081,"position":0},"title":"Another PowerShell Valentine","author":"Jeffery Hicks","date":"February 14, 2014","format":false,"excerpt":"I've been sharing some Valentine's Day themed fun on Twitter today. This one is a bit too long to fit into a tweet. $text = \"Happy$([char]3)Valentine's$([char]3)Day\" $text.ToCharArray() | foreach -begin { $colors = \"Cyan\",\"Magenta\",\"Yellow\",\"White\",\"Red\",\"DarkRed\",\"Green\" } -process { write-host $_ -NoNewline -ForegroundColor ($colors| Get-Random)} -end {\"`n\"} To get the full effect\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":7479,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7479\/friday-fun-with-powershell-and-ansi\/","url_meta":{"origin":2081,"position":1},"title":"Friday Fun with PowerShell and ANSI","author":"Jeffery Hicks","date":"May 15, 2020","format":false,"excerpt":"Ever since PowerShell 7 came along, I've been having a lot of fun exploring what I can do with ANSI color escape sequences. And actually, even in Windows PowerShell you can use them. Although you need to use a different escape character. Run Get-PSReadlineOption to see what I'm talking about.\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\/05\/ansibar-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ansibar-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ansibar-2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ansibar-2.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ansibar-2.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":2098,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2098\/valentines-day-powershell-fun\/","url_meta":{"origin":2081,"position":2},"title":"Valentines Day PowerShell Fun","author":"Jeffery Hicks","date":"February 14, 2012","format":false,"excerpt":"In case you missed some of the fun on Twitter and Google Plus, here are the PowerShell valentines I sent today. These are intended to be run from the PowerShell console, not the ISE. Also, depending on your console font, you might get slightly different results. I use Lucida Console.\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\/2012\/02\/psvalentine.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1660,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1660\/friday-fun-what-a-char\/","url_meta":{"origin":2081,"position":3},"title":"Friday Fun What a CHAR!","author":"Jeffery Hicks","date":"September 23, 2011","format":false,"excerpt":"Last week I posted a PowerShell snippet on Twitter. My original post piped an array of integers as [CHAR] type using an OFS. Don't worry about that. As many people reminded me, it is much easier to use the -Join operator. -join [char[]](116,103,105,102) I'll let you try that on your\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7489,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7489\/powershell-word-play\/","url_meta":{"origin":2081,"position":4},"title":"PowerShell Word Play","author":"Jeffery Hicks","date":"May 19, 2020","format":false,"excerpt":"A few weeks ago an Iron Scripter PowerShell challenge was issued that involved playing with words and characters. Remember, the Iron Scripter challenges aren't intended to create meaningful, production worthy code. They are designed to help you learn PowerShell fundamentals and scripting techniques. This particular challenge was aimed at beginner\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\/05\/doublechar.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":2622,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2622\/friday-fun-get-happy-holiday\/","url_meta":{"origin":2081,"position":5},"title":"Friday Fun &#8211; Get Happy Holiday","author":"Jeffery Hicks","date":"December 7, 2012","format":false,"excerpt":"Today's Friday Fun is my version of a script originally posted a few years ago by The PowerShell Guy. I'll list the code but you really need to run it to enjoy it. #requires -version 2.0 #This must be run from the PowerShell console. NOT in the ISE. #this is\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2081","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=2081"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2081\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}