{"id":17071,"date":"2010-09-19T00:01:00","date_gmt":"2010-09-19T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/09\/19\/draw-boxes-and-lines-in-the-windows-powershell-console-host\/"},"modified":"2010-09-19T00:01:00","modified_gmt":"2010-09-19T00:01:00","slug":"draw-boxes-and-lines-in-the-windows-powershell-console-host","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/draw-boxes-and-lines-in-the-windows-powershell-console-host\/","title":{"rendered":"Draw Boxes and Lines in the Windows PowerShell Console Host"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><strong>Summary<\/strong>: Microsoft MVP Sean Kearney shows how to draw boxes and lines in the Windows PowerShell console while scripting three reusable functions.<\/p>\n<p>&nbsp;<\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. Just when I thought it was safe to open my email, I get a tweet from Sean Kearney saying he has a present for me. Low and behold, Sean has sent me a really cool article. <\/p>\n<p>Sean Kearney is a network administrator, a Microsoft Certified Technology Specialist in Windows Server Virtualization and Configuration, a Windows PowerShell MVP, and a Microsoft Certified Systems Engineer. Sean is a devoted and passionate computer enthusiast from the early 80s to the present day, having used just about every microcomputer ever. Sean taught himself computer programming with 65xxmachine code, working with many technologies\u2015but primarily Microsoft. Sean deals with &ldquo;anything thrown at him,&rdquo; from gnawed keyboards to recovery of Exchange servers to networking setups and isolating the realm of the unknown. Currently, he tests and deploys just about any new Microsoft Technology; he also deals with users in an enterprise class environment. Sean loves Windows PowerShell, Windows 7, and Hyper-V, in that order. You will often find him hanging out online at <a href=\"http:\/\/www.powershell.ca\/\">http:\/\/www.powershell.ca<\/a>.<\/p>\n<p>Here is Sean&rsquo;s article. <\/p>\n<p>&nbsp;<\/p>\n<p>I decided to have some fun. Because isn&rsquo;t that why we got into computers in the first place? It was fun on some level? We enjoyed it? Right? So I was thinking back to my BBS days and ASCII art and plotting information on the console screen.<\/p>\n<p>You see, using the <strong>$HOST<\/strong> variable in Windows PowerShell allows you to move the cursor to any spot (within reason) on the console. After you have moved it, you can put something there. So I&rsquo;m thinking to myself, &ldquo;Boy, I&rsquo;d love to build a nice box on the screen!&rdquo; So I sat down and wrote a really bad script.&nbsp; It was bad because it worked, but the coding was just horrible and repetitive. What I ended up with (for a single box) was about four <strong>foreach<\/strong> loops, a whole pile of <strong>$host.ui.raw.cursorposition<\/strong> settings, and about 90 lines of code.<\/p>\n<p>Then I started reexamine it. Because a lot of the code did actually repeat in most respects, I thought there had to be a better way. The first part was easy. Make a function to position the cursor, mostly to make the code more readable, but also because I happen to like readable functions.<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Set<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Console<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Position<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">global:set-ConsolePosition<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">([int]<\/span><span style=\"color: #2b91af\">$x<\/span><span style=\"color: #000000\">,[int]<\/span><span style=\"color: #2b91af\">$y<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">current<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">cursor<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">position<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">and<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">store<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">away<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #2b91af\">$position<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$host<\/span><span style=\"color: #000000\">.ui.rawui.cursorposition<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Store<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">new<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">X<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">and<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Y<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Co-ordinates<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">away<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #2b91af\">$position<\/span><span style=\"color: #000000\">.x<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$x<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #2b91af\">$position<\/span><span style=\"color: #000000\">.y<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$y<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Place<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">modified<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">location<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">back<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">to<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$HOST<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #2b91af\">$host<\/span><span style=\"color: #000000\">.ui.rawui.cursorposition<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$position<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Set<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Console<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Position<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span> <\/div>\n<\/blockquote>\n<p>Next, I realized the code kept drawing lines. So I thought, &ldquo;Wouldn&rsquo;t it make more sense to have a smart function that could draw those lines&#8221;?&rdquo;<\/p>\n<p>So onto task number two. Make a function that doesn&rsquo;t just draw a line on the screen but would be smart enough to know whether I was doing it vertically or horizontally. It would have to know how long the line was and ideally what coordinates to draw it on.<\/p>\n<p>The function has to receive the X and Y position of where the line has to go, receive length, and know if it is a vertical line:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">global:draw-line([int]<\/span><span style=\"color: #2b91af\">$x<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[int]<\/span><span style=\"color: #2b91af\">$y<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[int]<\/span><span style=\"color: #2b91af\">$length<\/span><span style=\"color: #000000\">,[int]<\/span><span style=\"color: #2b91af\">$vertical<\/span><span style=\"color: #000000\">){<\/span><span style=\"color: #808080\">&nbsp;<\/span> <\/div>\n<\/blockquote>\n<p>Then set the line to start at the defined coordinates. My last function, <strong>set-ConsolePosition<\/strong>, makes this very easy:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">set-ConsolePosition<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$x<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$y<\/span> <\/div>\n<\/blockquote>\n<p>Now here&rsquo;s where the fun starts. I could just draw a box with asterisks and be done, but I&rsquo;d like it to look nicer. So each line will start with an asterisk but have a &ldquo;-&ldquo; or a &ldquo;!&rdquo;, depending on whether it&rsquo;s drawn vertically or horizontally:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">If<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">([boolean]<\/span><span style=\"color: #2b91af\">$vertical<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$linechar<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;!&#8221;<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #2b91af\">$horz<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">0<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">else<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$linechar<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;-&#8220;<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">0<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #2b91af\">$horz<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp;<\/span> <\/div>\n<\/blockquote>\n<p>Instead of a big funky <strong>{ if then else }<\/strong>, I decided to tie it into the math. So I sat down and thought out the flow of the code. Okay, all I did really was think &ldquo;If I&rsquo;m drawing vertically, the Y coordinate will always change; otherwise, X is always going to change&rdquo;:<\/p>\n<blockquote>\n<p><span style=\"color: #000000\">set-ConsolePosition<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">((<\/span><span style=\"color: #2b91af\">$horz<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$count<\/span><span style=\"color: #000000\">)+$x)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">((<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$count<\/span><span style=\"color: #000000\">)+$y)<\/span> <\/p>\n<\/blockquote>\n<p>So with this little line above here I make sure to keep the counter changing the value of the X position or the Y position (but not both) depending on how it receives the <strong>$Vertical<\/strong> from the function. This line<\/p>\n<blockquote>\n<p><span style=\"color: #0000ff\">write-host<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$linechar<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-nonewline<\/span> <\/p>\n<\/blockquote>\n<p>will always be the same for drawing because we have predefined the character we are drawing with. Overall, you get this to draw a line now:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">line<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">global:draw-line([int]<\/span><span style=\"color: #2b91af\">$x<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[int]<\/span><span style=\"color: #2b91af\">$y<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[int]<\/span><span style=\"color: #2b91af\">$length<\/span><span style=\"color: #000000\">,[int]<\/span><span style=\"color: #2b91af\">$vertical<\/span><span style=\"color: #000000\">){<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Move<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">to<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">assigned<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">X\/Y<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">position<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">in<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Console<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">set-ConsolePosition<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$x<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$y<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Beginning<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">of<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">line<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">write-host<\/span><span style=\"color: #808080\"> &#8220;*&#8221; <\/span><span style=\"color: #000000\">-nonewline<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Is<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">this<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">vertically<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">drawn<\/span><span style=\"color: #0000ff\">?<\/span><span style=\"color: #808080\">&nbsp; <\/span><span style=\"color: #0000ff\">Set<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">direction<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">variables<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">and<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">appropriate<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">character<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">to<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">draw<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">If<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">([boolean]<\/span><span style=\"color: #2b91af\">$vertical<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$linechar<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;!&#8221;<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #2b91af\">$horz<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">0<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">else<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$linechar<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;-&#8220;<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">0<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #2b91af\">$horz<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">length<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">of<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">line,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">moving<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">in<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">appropriate<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">direction<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">foreach<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$count<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">in<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">..(<\/span><span style=\"color: #2b91af\">$length-1<\/span><span style=\"color: #000000\">))<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">set-ConsolePosition<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">((<\/span><span style=\"color: #2b91af\">$horz<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$count<\/span><span style=\"color: #000000\">)+$x)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">((<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$count<\/span><span style=\"color: #000000\">)+$y)<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">write-host<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$linechar<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-nonewline<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Bump<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">up<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">counter<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">and<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">end<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #2b91af\">$count++<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">set-ConsolePosition<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">((<\/span><span style=\"color: #2b91af\">$horz<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$count<\/span><span style=\"color: #000000\">)+$x)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">((<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$count<\/span><span style=\"color: #000000\">)+$y)<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">write-host<\/span><span style=\"color: #808080\"> &#8220;*&#8221; <\/span><span style=\"color: #000000\">-nonewline<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">line<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span> <\/div>\n<\/blockquote>\n<p>Now here is where I went overboard. My brain went, &ldquo;Hey, I can draw a line, I can pick a direction, I could make a box!&rdquo; You can tell my brain didn&rsquo;t get a lot of vacation time during the summer. But I gave in and thought it out. Really, a box wasn&rsquo;t so difficult. Two horizontal lines, two vertical lines. I already have a function to draw lines.<\/p>\n<p>So I could just call up the line draw function with the appropriate data and just run it right? Nope. I could but there was this geeky little voice saying &ldquo;Reuse the code!&rdquo; So with a <strong>Foreach<\/strong> loop and some fancy math, I figured out a way to reuse almost every piece of sanity.<\/p>\n<p>So I thought, what is unique about each line in a box? The position, the X\/Y start position, and the length. So:<\/p>\n<ul>\n<li>The square would draw two horizontal lines and then two vertical lines. <\/li>\n<li>Each horizontal line the &ldquo;X&rdquo; position does not change for starting point. <\/li>\n<li>Each vertical line the &ldquo;Y&rdquo; position does not change for starting point. <\/li>\n<\/ul>\n<p>So you end up with a pattern like this:<\/p>\n<ul>\n<li>0 Horizontal <\/li>\n<li>0 Horizontal <\/li>\n<li>1 Vertical <\/li>\n<li>1 Vertical <\/li>\n<\/ul>\n<p>Each Row was either <strong>Top Left<\/strong> or <strong>Bottom Right<\/strong>:<\/p>\n<ul>\n<li>0 Top <\/li>\n<li>1 Bottom <\/li>\n<li>0 Left <\/li>\n<li>1 Right <\/li>\n<\/ul>\n<p>Which gave me this pattern:<\/p>\n<ul>\n<li>0 0 Top Horizontal <\/li>\n<li>0 1 Bottom Horizontal <\/li>\n<li>1 0 Left Vertical <\/li>\n<li>1 1 Right Vertical <\/li>\n<\/ul>\n<p>We have a loop that goes through four times and can flip variables and do all sorts of funky stuff to make a box.<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Box<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">global:draw-box<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">([int]<\/span><span style=\"color: #2b91af\">$width<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[int]<\/span><span style=\"color: #2b91af\">$length<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[int]<\/span><span style=\"color: #2b91af\">$x<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[int]<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$y<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Do<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">four<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">sides<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">foreach<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$box<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">in<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">0<\/span><span style=\"color: #000000\">..<\/span><span style=\"color: #800000\">3<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">to<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">flip<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">whether<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">we&rsquo;re<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">on<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">left<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">\/<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">top<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">of<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">box<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">or<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">not<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$side<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$box%2<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">to<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">switch<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">whether<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">it&rsquo;s<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">a<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">vertical<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">or<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">horizontal<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">line<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">[int]((<\/span><span style=\"color: #2b91af\">$box-<\/span><span style=\"color: #000000\">.<\/span><span style=\"color: #800000\">5<\/span><span style=\"color: #000000\">)\/<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">compute<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Width<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">and<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Length<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">so<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">we<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">can<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">&ldquo;switch<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">them&rdquo;<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$totalside<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$width+$length<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Length<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">of<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">line<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">will<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">be<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">dependant<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">on<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Direction<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(vertical<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">or<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Horizontal)<\/span><span style=\"color: #808080\">       <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$linelength<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$length<\/span><span style=\"color: #000000\">)+([int](!<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #000000\">)*<\/span><span style=\"color: #2b91af\">$width<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$result<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$totalside-$linelength<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">flip<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">in<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">correct<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">X<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Y<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">coordinates<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">for<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">maximum<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$ypass<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">([int](!<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #000000\">)*<\/span><span style=\"color: #2b91af\">$side<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$result<\/span><span style=\"color: #000000\">)+$y<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$xpass<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$side<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #2b91af\">$result<\/span><span style=\"color: #000000\">)+$x<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">line<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">draw-line<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$xpass<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$ypass<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$linelength<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$vert<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">       <br \/><\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Draw<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Box<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/span><span style=\"color: #808080\">&nbsp;<\/span> <\/div>\n<\/blockquote>\n<p>So what do we have ? A series of three functions, and a pretty box on the screen. <\/p>\n<p>What have we learned? <\/p>\n<ol>\n<li>You can use some incredibly powerful functions in Windows PowerShell. <\/li>\n<li>With proper math and functions, you can make a lot of code reusable. <\/li>\n<li>Sean has way too much time on his hands. <\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Sean, thank you for sending me your post. I put all three functions into a single script, loaded it into my Windows PowerShell console, moved my console point, and drew a box and a line. The results are shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7776.WES9191001_6BEE80E9.jpg\"><img decoding=\"async\" height=\"396\" width=\"554\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2577.WES9191001_thumb_50697EE6.jpg\" alt=\"Image of script results\" border=\"0\" title=\"Image of script results\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>We would love for you to follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to us at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Guys Forum<\/a>. See you tomorrow when we begin a new week on the Script Center. We will have an awesome series of articles about Windows PowerShell cmdlets and SharePoint 2010, written by celebrated SharePoint author Niklas Goude. Until then, peace.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><\/strong><\/p>\n<p><strong>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Summary: Microsoft MVP Sean Kearney shows how to draw boxes and lines in the Windows PowerShell console while scripting three reusable functions. &nbsp; Microsoft Scripting Guy Ed Wilson here. Just when I thought it was safe to open my email, I get a tweet from Sean Kearney saying he has a present for me. [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[71,56,3,4,154,61,45],"class_list":["post-17071","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-graphical","tag-guest-blogger","tag-scripting-guy","tag-scripting-techniques","tag-sean-kearney","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; Summary: Microsoft MVP Sean Kearney shows how to draw boxes and lines in the Windows PowerShell console while scripting three reusable functions. &nbsp; Microsoft Scripting Guy Ed Wilson here. Just when I thought it was safe to open my email, I get a tweet from Sean Kearney saying he has a present for me. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=17071"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17071\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=17071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=17071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=17071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}