{"id":3573,"date":"2013-12-09T11:59:15","date_gmt":"2013-12-09T16:59:15","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3573"},"modified":"2013-12-09T11:59:15","modified_gmt":"2013-12-09T16:59:15","slug":"updated-console-graphing-in-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/","title":{"rendered":"Updated Console Graphing in PowerShell"},"content":{"rendered":"<p>The other day Distinguished Engineer and PowerShell Godfather Jeffrey Snover posted a blog article about <a href=\"http:\/\/www.jsnover.com\/blog\/2013\/12\/07\/write-host-considered-harmful\/\" title=\"Read why Write-Host is considered harmful\" target=\"_blank\">the evils of Write-Host<\/a>. His take, which many agree with, is that Write-Host is a special case cmdlet. In his article he mentions console graphing as an example. I wrote such a script earlier this year. Mr. Snover's post drove some new attention to my post and I realized it needed a little polishing.<\/p>\n<p>Here is a revised version of that script. <\/p>\n<pre class=\"lang:ps decode:true \" >#requires -version 3.0\r\n\r\nFunction Out-ConsoleGraph {\r\n\r\n&lt;#\r\n.Synopsis\r\nCreate a console-based chart\r\n.Description\r\nThis command takes objects and creates a horizontal bar graph based on the \r\nproperty you specify. The property should return a numeric value. This command\r\ndoes NOT write anything to the pipeline. All output is to the PowerShell host.\r\n\r\nThe default behavior is to use the same color, Green, for all graphed values.\r\nBut you can specify conditional coloring using -HighColor, -MediumColor and\r\n-LowColor. If you specify one you must specify all three. The maximum available\r\ngraph value is divided into thirds. The top third will be considered high, the\r\nnext third medium and the rest low.\r\n\r\nThe final option is to send the graph results to Out-Gridview. But, you cannot\r\nuse conditional formatting nor specify a graph color. However, the grid view will\r\ninclude the property value.\r\n\r\nThis command should work in both the Windows PowerShell console and PowerShell \r\nISE. There is no guarantee it will work with any other PowerShell host.\r\n\r\n.Parameter Property\r\nThe name of the property to graph.\r\n.Parameter CaptionProperty\r\nThe name of the property to use as the caption. The default is Name.\r\n.Parameter Title\r\nA string for the title of your graph. The default is &lt;Property&gt; Report - &lt;date&gt;\r\n.Parameter DefaultColor\r\nThe default console color to use for the graph\r\n.Parameter HighColor\r\nThe console color to use for the top 1\/3 of graphed values.\r\n.Parameter MediumColor\r\nThe console color to use for the middle 1\/3 of graphed values.\r\n.Parameter LowColor\r\nThe console color to use for the bottom 1\/3 of graphed values.\r\n.Parameter ClearScreen\r\nClear the screen before displaying the graph. The parameter has an alias of cls.\r\n.Parameter GridView\r\nCreate a graph using Out-Gridview. The parameter has an alias of ogv\r\n.Example\r\nPS C:\\&gt; Get-Process | Out-ConsoleGraph -property WorkingSet -clearscreen\r\n.Example\r\nPS C:\\&gt; $computer=$env:computername\r\nPS C:\\&gt; Get-CimInstance Win32_logicaldisk -filter \"drivetype=3\" -computer $computer | \r\nout-ConsoleGraph -property Freespace -Title \"FreeSpace Report for $computer on $(Get-Date)\"\r\n\r\nThis example assumes the computer has more than one logical disk.\r\n.Example\r\nPS C:\\&gt; get-vm | where state -eq 'running' | out-consolegraph -Property MemoryAssigned -GraphColor Red\r\n\r\nGet all running virtual machines using the Hyper-V Get-VM cmdlet and display a graph\r\ndepicting MemoryAssigned.\r\n.Example\r\nPS C:\\&gt; \"chi-dc01\",\"chi-dc02\",\"chi-dc04\",\"chi-fp02\" | foreach -Begin {cls} { \r\n  $computer=$_\r\n  Get-CimInstance win32_logicaldisk -filter \"deviceID='C:'\" -ComputerName $computer |\r\n  Select Caption,PSComputername, @{Name=\"PercentFree\";Expression={ [int](($_.FreeSpace\/$_.Size)*100)}} \r\n  } |  Out-ConsoleGraph -property PercentFree -title \"Freespace Report - $(Get-Date)\" -CaptionProperty PSComputername -HighColor DarkGreen -MediumColor White -LowColor Red\r\n\r\nThis example will create a console graph showing percent free space on Drive C: for several computers.\r\n.Example\r\nPS C:\\&gt; get-process | where {$_.cpu} | out-consolegraph CPU -high Red -medium magenta -low yellow\r\n.Example\r\nPS C:\\&gt; get-process | where {$_.cpu} | out-consolegraph CPU -high Red -medium magenta -low yellow -verbose 4&gt;&amp;1&gt;verb.txt\r\n\r\nRun the previous example to create a conditional color chart and send verbose data to a text file.\r\n.Example\r\nPS C:\\&gt; get-process | where {$_.cpu} | Sort CPU -descending | Out-Consolegraph CPU -Caption ID -Grid\r\n\r\nVery similar to previous example except output is to Out-Gridview and the process ID is \r\ndisplayed instead of the process name.\r\n.Example\r\nPS Scripts:\\&gt; (dir *.txt).where{$_.length -gt 50KB} | ocg length\r\n\r\nThis is a PowerShell 4.0 example that will create a console graph for all .txt \r\nfiles in the Scripts folder greater than 50KB in size. this example is using the\r\noptional ocg alias for Out-ConsoleGraph.\r\n.Example\r\nPS C:\\&gt; $PSDefaultParameterValues.Add(\"Out-ConsoleGraph:HighColor\",\"Red\")\r\nPS C:\\&gt; $PSDefaultParameterValues.Add(\"Out-ConsoleGraph:MediumColor\",\"Yellow\")\r\nPS C:\\&gt; $PSDefaultParameterValues.Add(\"Out-ConsoleGraph:LowColor\",\"Green\")\r\nPS C:\\&gt; (dir c:\\scripts\\*.txt).where{$_.length -gt 50KB} | Add-member -membertype Aliasproperty -Name Size -value Length -passthru | ocg Size -Title \"C:\\Scripts Text Report $((Get-Date).ToShortDateString())\"\r\n\r\nThis command creates default parameter values for conditional colors so you don't\r\nhave to specify them. It also creates an alias property of Size for the Length \r\nproperty and uses that instead.  The .Where syntax requires PowerShell 4.0.\r\n\r\n.Link\r\nWrite-Host\r\nOut-Gridview\r\n.Link\r\nhttp:\/\/jdhitsolutions.com\/blog\/2013\/12\/updated-console-graphing-in-powershell\r\n.Inputs\r\nObject\r\n.Outputs\r\nNone\r\n.Notes\r\n\r\nVersion:  3.1\r\nUpdated:  12\/9\/2013\r\nAuthor :  Jeffery Hicks (http:\/\/jdhitsolutions.com\/blog)\r\n\r\nDiscover and Learn PowerShell:\r\n -&gt; Learn Windows PowerShell 3 in a Month of Lunches\r\n -&gt; Learn PowerShell Toolmaking in a Month of Lunches\r\n -&gt; PowerShell in Depth: An Administrator's Guide\r\n -&gt; PowerShell Deep Dives\r\n\r\n\r\n#&gt; \r\n\r\n[cmdletbinding(DefaultParameterSetName=\"Single\")]\r\n\r\nParam (\r\n[parameter(Position=0,Mandatory=$True,HelpMessage=\"Enter a property name to graph\")]\r\n[ValidateNotNullorEmpty()]\r\n[string]$Property,\r\n[parameter(Position=1,ValueFromPipeline=$True)]\r\n[object]$Inputobject,\r\n[string]$CaptionProperty=\"Name\",\r\n[string]$Title=\"$Property Report - $(Get-Date)\",\r\n[Parameter(ParameterSetName=\"Single\")]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"graphColor\")]\r\n[System.ConsoleColor]$DefaultColor=\"Green\",\r\n[Parameter(ParameterSetName=\"Conditional\",Mandatory=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[System.ConsoleColor]$HighColor,\r\n[Parameter(ParameterSetName=\"Conditional\",Mandatory=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[System.ConsoleColor]$MediumColor,\r\n[Parameter(ParameterSetName=\"Conditional\",Mandatory=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[System.ConsoleColor]$LowColor,\r\n[alias(\"cls\")]\r\n[switch]$ClearScreen,\r\n[Parameter(ParameterSetName=\"Grid\")]\r\n[Alias(\"ogv\")]\r\n[switch]$GridView\r\n)\r\n\r\nBegin {\r\n    Set-StrictMode -Version latest\r\n\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n    Write-Verbose -Message \"Parameter set $($pscmdlet.ParameterSetName)\"\r\n\r\n    #get the current window width so that our lines will be proportional\r\n    $Width = $Host.UI.RawUI.BufferSize.Width\r\n    Write-Verbose \"Width = $Width\"\r\n    \r\n    #initialize an array to hold data. We will process all the data at the end.\r\n    $data=@()\r\n    if ($pscmdlet.ParameterSetName -eq 'Grid') {\r\n        Write-Verbose \"Initializing gvData\"\r\n        $gvData = @()\r\n    }\r\n} #begin\r\n\r\nProcess {\r\n    #get the data from the pipelined input and add it to the array\r\n    $data += $Inputobject\r\n\r\n} #end process\r\n\r\nEnd {\r\n    #get largest property value\r\n    Write-Verbose \"Getting largest value for $property\"\r\n    Try {\r\n       &lt;#\r\n       Modified this original line per Lee Holmes to handle piped objects that\r\n       might not have the same property such as Directory and File. \r\n       $largest = $data | sort $property | Select -ExpandProperty $property -last 1 -ErrorAction Stop\r\n       #&gt;\r\n       $largest = $data | Foreach-Object { $_.$property } | Sort-Object | Select-Object -last 1\r\n        Write-Verbose $largest\r\n    }\r\n    Catch {\r\n        Write-Warning \"Failed to find property $property\"\r\n        #bail out of the command\r\n        Return\r\n    }\r\n    If ($largest) {\r\n        #get length of longest object property used for the caption so we can pad\r\n        #This must be a string so we can get the length\r\n        Write-Verbose \"Getting longest value for $CaptionProperty\"\r\n        $sample = $data | \r\n        Sort-object -Property @{Expression={($_.$CaptionProperty -as [string]).Length}} |\r\n        Select-Object -last 1\r\n        \r\n        Write-Verbose ($sample | out-string)\r\n        [int]$longest = ($sample.$CaptionProperty).ToString().length\r\n        \r\n        Write-Verbose \"Longest caption is $longest\"\r\n\r\n        #get remaining available window width, dividing by 100 to get a \r\n        #proportional width. Subtract 4 to add a little margin.\r\n        $available = ($width-$longest-4)\/100\r\n        Write-Verbose \"Available value is $available\"\r\n\r\n        #calculate high, medium and low ranges based on available\r\n        $HighValue = ($available*100) * 0.6666\r\n        $MediumValue = ($available*100) * 0.3333\r\n        #low values will be 1 to $MediumValue\r\n        Write-Verbose \"High value will be $HighValue\"\r\n        Write-Verbose \"Medium value will be $MediumValue\"\r\n    \r\n        if ($ClearScreen) {\r\n            Clear-Host\r\n        }\r\n        Write-Host \"`n$Title`n\"\r\n        foreach ($obj in $data) {\r\n            #define the caption\r\n            [string]$caption = $obj.$captionProperty\r\n\r\n            &lt;#\r\n             calculate the current property as a percentage of the largest \r\n             property in the set. Then multiply by the remaining window width\r\n            #&gt;\r\n            if ($obj.$property -eq 0) {\r\n                #if property is actually 0 then don't display anything for the graph\r\n                [int]$graph=0\r\n            }\r\n            else {\r\n                $graph = (($obj.$property)\/$largest)*100*$available\r\n            }\r\n            if ($graph -ge 2) {\r\n                [string]$g=[char]9608\r\n            }\r\n            elseif ($graph -gt 0 -AND $graph -le 1) {\r\n                #if graph value is &gt;0 and &lt;1 then use a short graph character\r\n                [string]$g=[char]9612\r\n                #adjust the value so something will be displayed\r\n                $graph=1\r\n            }\r\n            \r\n            Write-Verbose \"Graph value is $graph\"\r\n            Write-Verbose \"Property value is $($obj.$property)\"\r\n\r\n            #send to Out-Gridview if specified\r\n            if ($pscmdlet.ParameterSetName -eq \"Grid\") {\r\n                #add each object to the gridview data array\r\n                $gvHash = [ordered]@{\r\n                $CaptionProperty = $caption\r\n                $Property = ($g*$graph) \r\n                Value = $obj.$Property\r\n                } \r\n                $gvData += New-Object -TypeName PSObject -Property $gvHash\r\n            }\r\n            Else {\r\n                Write-Host $caption.PadRight($longest) -NoNewline\r\n                #add some padding between the caption and the graph\r\n                Write-Host \"  \" -NoNewline\r\n                if ($pscmdlet.ParameterSetName -eq \"Single\") {\r\n                    $GraphColor = $DefaultColor\r\n                }\r\n                else {\r\n                    #using conditional coloring based on value of $graph\r\n                    if ($Graph -ge $HighValue) {\r\n                        $GraphColor = $HighColor\r\n                    }\r\n                    elseif ($graph -ge $MediumValue) {\r\n                        $GraphColor = $MediumColor\r\n                    }\r\n                    else {\r\n                        $GraphColor = $LowColor\r\n                    }\r\n                } #else console\r\n                \r\n                Write-Host ($g*$graph) -ForegroundColor $GraphColor\r\n            } #not gridview\r\n        } #foreach\r\n           #add a blank line\r\n           Write-Host `n\r\n    } #if $largest\r\n\r\n    if ($pscmdlet.ParameterSetName -eq \"Grid\") {\r\n      Write-Verbose \"Sending data to Out-Gridview\"\r\n      $gvData | Out-GridView -Title $Title \r\n    }\r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n} #end Out-ConsoleGraph\r\n\r\n#define an optional alias\r\nSet-Alias -Name ocg -Value Out-ConsoleGraph<\/pre>\n<p>I didn't make too many structural changes other than to add Set-StrictMode and revise some of my IF statements to test for ParameterSetName instead of a variable. Using StrictMode, which is a good thing, caused problems in my earlier version. I also went through and added some new examples, including a few PowerShell 4.0.  <\/p>\n<p>The function still requires at least PowerShell 3.0. But it allows you to do something like this:<\/p>\n<pre class=\"lang:ps decode:true \" >$computers = \"chi-dc01\",\"chi-dc02\",\"chi-dc04\",\"chi-fp02\",\"chi-core01.globomantics.local\",\"chi-app01\"\r\n$computers | foreach -Begin {cls} { \r\n  $computer=$_\r\n  Get-CimInstance win32_logicaldisk -filter \"deviceID='C:'\" -ComputerName $computer |\r\n  Select Caption,SystemName, @{Name=\"PercentFree\";Expression={ [int](($_.FreeSpace\/$_.Size)*100)}} \r\n  } |  Out-ConsoleGraph -property PercentFree -title \"Globomantics Freespace Report - $((Get-Date).ToShortDateString())\" -CaptionProperty SystemName -HighColor DarkGreen -MediumColor magenta -LowColor Red\r\n<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1-300x88.png\" alt=\"out-consolegraph-3.1\" width=\"300\" height=\"88\" class=\"aligncenter size-medium wp-image-3574\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1-300x88.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1-624x184.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1.png 877w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>All you can do is look at this but sometimes, that's all you need.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other day Distinguished Engineer and PowerShell Godfather Jeffrey Snover posted a blog article about the evils of Write-Host. His take, which many agree with, is that Write-Host is a special case cmdlet. In his article he mentions console graphing as an example. I wrote such a script earlier this year. Mr. Snover&#8217;s post drove&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New from the blog: Updated Console Graphing in #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":[359],"tags":[534,101],"class_list":["post-3573","post","type-post","status-publish","format-standard","hentry","category-powershell-3-0","tag-powershell","tag-write-host"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Updated Console Graphing in PowerShell &#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-3-0\/3573\/updated-console-graphing-in-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Updated Console Graphing in PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"The other day Distinguished Engineer and PowerShell Godfather Jeffrey Snover posted a blog article about the evils of Write-Host. His take, which many agree with, is that Write-Host is a special case cmdlet. In his article he mentions console graphing as an example. I wrote such a script earlier this year. Mr. Snover&#039;s post drove...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-12-09T16:59:15+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1-300x88.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=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Updated Console Graphing in PowerShell\",\"datePublished\":\"2013-12-09T16:59:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/\"},\"wordCount\":168,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/12\\\/out-consolegraph-3.1-300x88.png\",\"keywords\":[\"PowerShell\",\"Write-Host\"],\"articleSection\":[\"Powershell 3.0\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/\",\"name\":\"Updated Console Graphing in PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/12\\\/out-consolegraph-3.1-300x88.png\",\"datePublished\":\"2013-12-09T16:59:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/12\\\/out-consolegraph-3.1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/12\\\/out-consolegraph-3.1.png\",\"width\":877,\"height\":259},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-3-0\\\/3573\\\/updated-console-graphing-in-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Powershell 3.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-3-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Updated Console Graphing in 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":"Updated Console Graphing in PowerShell &#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-3-0\/3573\/updated-console-graphing-in-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Updated Console Graphing in PowerShell &#8226; The Lonely Administrator","og_description":"The other day Distinguished Engineer and PowerShell Godfather Jeffrey Snover posted a blog article about the evils of Write-Host. His take, which many agree with, is that Write-Host is a special case cmdlet. In his article he mentions console graphing as an example. I wrote such a script earlier this year. Mr. Snover's post drove...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-12-09T16:59:15+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1-300x88.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":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Updated Console Graphing in PowerShell","datePublished":"2013-12-09T16:59:15+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/"},"wordCount":168,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1-300x88.png","keywords":["PowerShell","Write-Host"],"articleSection":["Powershell 3.0"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/","name":"Updated Console Graphing in PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1-300x88.png","datePublished":"2013-12-09T16:59:15+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/out-consolegraph-3.1.png","width":877,"height":259},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-3-0\/3573\/updated-console-graphing-in-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Powershell 3.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},{"@type":"ListItem","position":2,"name":"Updated Console Graphing in 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":2697,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2697\/powershell-console-graphing-revised\/","url_meta":{"origin":3573,"position":0},"title":"PowerShell Console Graphing Revised","author":"Jeffery Hicks","date":"January 11, 2013","format":false,"excerpt":"Many of you have been having fun with my PowerShell Console Graphing tool I posted the other day. But I felt the need to make one more major tweak. I wanted to have the option for conditional formatting. That is, display graphed entries with high values in one color, medium\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"out-consolegraph-3","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-3-1024x816.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-3-1024x816.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-3-1024x816.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2679,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2679\/graphing-with-the-powershell-console\/","url_meta":{"origin":3573,"position":1},"title":"Graphing with the PowerShell Console","author":"Jeffery Hicks","date":"January 9, 2013","format":false,"excerpt":"I've written before about using the PowerShell console as a graphing tool, primarily using Write-Host. Most of what I've published before were really proof of concept. I decided to try and come up with a more formal and re-usable tool that could create a horizontal bar graph based on a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"out-consolegraph-1","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-1-1024x735.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-1-1024x735.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-1-1024x735.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2704,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2704\/powershell-graphing-with-out-gridview\/","url_meta":{"origin":3573,"position":2},"title":"PowerShell Graphing with Out-Gridview","author":"Jeffery Hicks","date":"January 14, 2013","format":false,"excerpt":"I've received a lot of interest for my last few posts on graphing with the PowerShell console. But I decided I could add one more feature. Technically it might have made more sense to turn this into a separate function, but I decided to simply modify the last version of\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"out-consolegraph-gv","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-gv-1024x548.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-gv-1024x548.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/out-consolegraph-gv-1024x548.png?resize=525%2C300 1.5x"},"classes":[]},{"id":3032,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3032\/powershell-version-profiles\/","url_meta":{"origin":3573,"position":3},"title":"PowerShell Version Profiles","author":"Jeffery Hicks","date":"May 15, 2013","format":false,"excerpt":"One of the best things about PowerShell 3.0, for me anyway, is the ability to run PowerShell 2.0 side by side. I often need to test commands and scripts in both versions not only for my writing projects but also when helping people out. Like many of you I have\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"talkbubble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3912,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3912\/friday-fun-a-random-powershell-console\/","url_meta":{"origin":3573,"position":4},"title":"Friday Fun: A Random PowerShell Console","author":"Jeffery Hicks","date":"July 11, 2014","format":false,"excerpt":"This week I thought we'd have a little fun with the PowerShell console and maybe pick up a few scripting techniques along the way. Today I have a function that changes the foreground and background colors of your PowerShell console to random values. But because you might want to go\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"crayons","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/crayons-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3455,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3455\/friday-fun-color-my-web\/","url_meta":{"origin":3573,"position":5},"title":"Friday Fun Color My Web","author":"Jeffery Hicks","date":"September 20, 2013","format":false,"excerpt":"Awhile ago I posted an article demonstrating using Invoke-Webrequest which is part of PowerShell 3.0. I used the page at Manning.com to display the Print and MEAP bestsellers. By the way, thanks to all of you who keep making PowerShell books popular. My original script simply wrote the results to\u2026","rel":"","context":"In &quot;Books&quot;","block_context":{"text":"Books","link":"https:\/\/jdhitsolutions.com\/blog\/category\/books\/"},"img":{"alt_text":"get-manningbestseller1","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-manningbestseller1-1024x606.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-manningbestseller1-1024x606.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/get-manningbestseller1-1024x606.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3573","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=3573"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3573\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}