{"id":3872,"date":"2014-05-30T11:26:09","date_gmt":"2014-05-30T15:26:09","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3872"},"modified":"2015-08-19T14:33:59","modified_gmt":"2015-08-19T18:33:59","slug":"friday-fun-with-formatting","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/","title":{"rendered":"Friday Fun with Formatting"},"content":{"rendered":"<p>PowerShell is very adept at retrieving all sorts of information from computer systems in your network. Often the data is in a format that is hard to digest at a glance. For example, when you see a value like 1202716672 is that something in MB or GB? What if you need to view that value as KB? I don't know about you but I'm not good at making those conversions in my head and on-the-fly. Instead, we often resort to commands like this.<\/p>\n<pre class=\"lang:batch decode:true \">PS C:\\&gt; get-ciminstance win32_computersystem | select Name,Number*,@{Name=\"MemGB\";Expression={$_.totalphysicalmemory\/1gb -as [int]}},Manufacturer\r\n\r\n\r\nName                      : WIN81-ENT-01\r\nNumberOfLogicalProcessors : 4\r\nNumberOfProcessors        : 1\r\nMemGB                     : 8\r\nManufacturer              : LENOVO<\/pre>\n<p>That is much easier than seeing a value of 8589934592. The same thing applies when it comes to calculating percentages. Again, we're back to using custom hashtables with Select-Object. Of course, you can go the extra mile and create custom format and type extensions. But sometimes, at least speaking for myself, you want something in between. So I created two functions, Format-Value and Format-Percent and packaged them as a module.<\/p>\n<pre class=\"lang:ps decode:true \">Function Format-Percent {\r\n\r\n&lt;#\r\n.Synopsis\r\nCalculate a percent\r\n.Description\r\nThis command calculates a percentage of a value from a total, with the formula (value\/total)*100. The default is to return a value to 2 decimal places but you can configure that with -Decimal. There is also an option to format the percentage as a string which will include the % symbol.\r\n.Parameter Value\r\nThe numerator value. The parameter has aliases of X and Numerator.\r\n.Parameter Total\r\nThe denominator value. The parameter has aliases of Y and Denominator.\r\n.Parameter Decimal\r\nThe number of decimal places to return between 0 and 15.\r\n.Parameter String\r\nFormat the percentage as a string which will include the % symbol. This is done using the -f operator.\r\n.Example\r\nPS C:\\&gt; Format-Percent 1234 5000\r\n24.68\r\n.Example\r\nPS C:\\&gt; get-ciminstance win32_operatingsystem -computer chi-dc04 | select PSComputername,TotalVisibleMemorySize,@{Name=\"PctFreeMem\";Expression={ Format-Percent $_.FreePhysicalMemory $_.TotalVisibleMemorySize  }}\r\n\r\nPSComputerName             TotalVisibleMemorySize           PctFreeMem\r\n--------------             ----------------------           ----------\r\nchi-dc04                                  1738292                23.92\r\n.Example\r\nPS C:\\&gt; get-ciminstance win32_operatingsystem -computer chi-dc04 | select PSComputername,TotalVisibleMemorySize,@{Name=\"PctFreeMem\";Expression={ Format-Percent $_.FreePhysicalMemory $_.TotalVisibleMemorySize -asString  }}\r\nPSComputerName             TotalVisibleMemorySize           PctFreeMem\r\n--------------             ----------------------           ----------\r\nchi-dc04                                  1738292           23.92%\r\n\r\n\r\n.Notes\r\nLast Updated: May 30, 2014\r\nVersion     : 1.0\r\n\r\n#&gt;\r\n\r\n[cmdletbinding(DefaultParameterSetName=\"None\")]\r\nParam(\r\n[Parameter(Position=0,Mandatory,HelpMessage=\"What is the value?\")]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"X\",\"Numerator\")]\r\n$Value,\r\n[Parameter(Position=1,Mandatory,HelpMessage=\"What is the total value?\")]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"Y\",\"Denominator\")]\r\n$Total,\r\n[ValidateNotNullorEmpty()]\r\n[ValidateRange(0,15)]\r\n[int]$Decimal=2,\r\n[Parameter(ParameterSetName=\"String\")]\r\n[Switch]$AsString\r\n)\r\n\r\nWrite-Verbose \"Calculating percentage from $Value\/$Total to $decimal places\"\r\n$result = $Value\/$Total\r\n\r\nif ($AsString) {\r\n    Write-Verbose \"Writing string result\"\r\n    $pctstring = \"{0:p$Decimal}\" -f $result\r\n    #remove the space before the % symbol\r\n    $pctstring.Replace(\" \",\"\")\r\n\r\n}\r\nelse {\r\n    Write-Verbose \"Writing numeric result\"\r\n    [math]::Round( ($result*100),$Decimal)\r\n}\r\n\r\n} #end function\r\n\r\n\r\nFunction Format-Value {\r\n\r\n&lt;#\r\n.Synopsis\r\nFormat a numeric value\r\n.Description\r\nThis command will format a given numeric value. By default it will treat the number as an integer. Or you can specify a certain number of decimal places. The command will also allow you to format the value in KB, MB, etc. Or you can let the command autodetect the value and divide by an appropriate value.\r\n.Parameter Unit\r\nThe unit of measurement for your value. Valid choices are \"KB\",\"MB\",\"GB\",\"TB\", and \"PB\". If you don't specify a unit, the value will remain as is, although you can still specify the number of decimal places.\r\n.Parameter Decimal\r\nThe number of decimal places to return between 0 and 15.\r\n\r\n.Example\r\nPS C:\\&gt; Get-CimInstance -class win32_logicaldisk -filter \"DriveType=3\" | Select DeviceID,@{Name=\"SizeGB\";Expression={$_.size | format-value -unit GB}},@{Name=\"FreeGB\";Expression={$_.freespace | format-value -unit GB -decimal 2}}\r\n\r\nDeviceID                            SizeGB                                      FreeGB\r\n--------                            ------                                      ------\r\nC:                                     200                                      124.97\r\nD:                                     437                                       29.01\r\nE:                                      25                                        9.67\r\n.Example\r\nPS C:\\&gt; (get-process chrome | measure ws -sum ).sum | format-value -Autodetect -verbose -Decimal 4\r\nVERBOSE: Formatting 1180504064\r\nVERBOSE: Using Autodetect\r\nVERBOSE: ..as GB\r\nVERBOSE: Reformatting 1.09943008422852\r\nVERBOSE: ..to 4 decimal places\r\n1.0994\r\n.Notes\r\nLast Updated: 5\/29\/2014\r\nVersion     : 1.0\r\n\r\n\r\n#&gt;\r\n\r\n[cmdletbinding(DefaultParameterSetName=\"Default\")]\r\nParam(\r\n[Parameter(Position=1,Mandatory,ValueFromPipeline)]\r\n[ValidateNotNullorEmpty()]\r\n$InputObject,\r\n[Parameter(Position=0,ParameterSetName=\"Default\")]\r\n[ValidateSet(\"KB\",\"MB\",\"GB\",\"TB\",\"PB\")]\r\n[string]$Unit,\r\n[ValidateRange(0,15)]\r\n[int]$Decimal,\r\n[Parameter(ParameterSetName=\"Auto\")]\r\n[switch]$Autodetect\r\n)\r\n\r\nProcess {\r\n    Write-Verbose \"Formatting $Inputobject\"\r\n    if ($PSCmdlet.ParameterSetName -EQ \"Default\") {\r\n    Write-Verbose \"..as $Unit\"\r\n    Switch ($Unit) {\r\n     \"KB\" { $value =  $Inputobject \/ 1KB ; break }\r\n     \"MB\" { $value =  $Inputobject \/ 1MB ; break }\r\n     \"GB\" { $value =  $Inputobject \/ 1GB ; break }\r\n     \"TB\" { $value =  $Inputobject \/ 1TB ; break }\r\n     \"PB\" { $value =  $Inputobject \/ 1PB ; break }\r\n     default { \r\n      #just use the raw value\r\n      $value = $Inputobject \r\n      }\r\n    } #switch\r\n    }\r\n    else {\r\n      Write-Verbose \"Using Autodetect\"\r\n      \r\n      if ($InputObject -ge 1PB) {\r\n        Write-Verbose \"..as PB\"\r\n        $value =  $Inputobject \/ 1PB\r\n      }\r\n      elseif ($InputObject -ge 1TB) {\r\n        Write-Verbose \"..as TB\"\r\n        $value =  $Inputobject \/ 1TB\r\n      }\r\n      elseif ($InputObject -ge 1GB) {\r\n        Write-Verbose \"..as GB\"\r\n        $value =  $Inputobject \/ 1GB\r\n      }\r\n      elseif ($InputObject -ge 1MB) {\r\n        Write-Verbose \"..as MB\"\r\n        $value =  $Inputobject \/ 1MB\r\n      }\r\n      elseif ($InputObject -ge 1KB) {\r\n        Write-Verbose \"..as KB\"\r\n        $value =  $Inputobject \/ 1KB\r\n      }\r\n      else { \r\n        Write-Verbose \"..as bytes\"\r\n        $value = $InputObject\r\n      }\r\n\r\n    }\r\n    Write-Verbose \"Reformatting $value\"\r\n    if ($decimal) {\r\n        Write-Verbose \"..to $decimal decimal places\"\r\n        [math]::Round($value,$decimal)\r\n    }\r\n    else {\r\n        Write-verbose \"..as [int]\"\r\n        $value -as [int]\r\n    }\r\n} #process\r\n} \r\n\r\nSet-Alias -Name fv -Value Format-Value\r\nSet-Alias -Name fp -value Format-Percent\r\n\r\nExport-ModuleMember -Function * -Alias *<\/pre>\n<p>Format-Value will take any value and by default round it to an integer. Or you can specify to format the value as a certain unit of measurement such as GB or MB. You can even specify the number of decimal places. Or, you can use the -Autodetect parameter and the function will make the best guess about the 'size' of your value. Use -Verbose if you want to know what unit it detects.<\/p>\n<p>I did a similar thing with percentages. All you have to do is specify a value and a total and the function does the rest. Again, you can specify the number of decimal places. By default, the function writes a numeric value to the pipeline which I find makes it easier if you want to sort. But you can also specify to get a percentage as a string which will use the -f operator. The string will include the % symbol. I take an extra step to remove the space between the value and symbol.<\/p>\n<p>With the function, my PowerShell expressions become a little easier to write.<\/p>\n<pre class=\"lang:ps decode:true \">Get-CimInstance -class win32_logicaldisk -filter \"DriveType=3\" |\r\nSelect DeviceID,\r\n@{Name=\"SizeGB\";Expression={$_.size | fv -unit GB}},\r\n@{Name=\"FreeGB\";Expression={$_.freespace | fv -unit GB -decimal 2}},\r\n@{Name=\"PctFree\";Expression={fp -x $_.freespace -y $_.size}}\r\n<\/pre>\n<p>In the code sample I'm using the function and parameter aliases. But I like the result.<br \/>\n<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-3873\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-300x73.png\" alt=\"formatfunctions\" width=\"300\" height=\"73\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-300x73.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-1024x251.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions.png 1324w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/FormatFunctions.zip\">FormatFunctions.zip<\/a> extract it to your modules directory and you should be good to go. I've set the minimum PowerShell version to 3.0 although there's nothing I can think of that would prevent these commands from working on v2. But I'd like to drive you to at least 3 anyway.<\/p>\n<p>I hope you'll let me know what you think and what other types of data formatting you'd like to see added to the module.<\/p>\n<p>NOTE: An update has been posted at <a href=\"http:\/\/bit.ly\/1PzSnJa\">http:\/\/bit.ly\/1PzSnJa<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PowerShell is very adept at retrieving all sorts of information from computer systems in your network. Often the data is in a format that is hard to digest at a glance. For example, when you see a value like 1202716672 is that something in MB or GB? What if you need to view that value&#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":"Friday Fun with Formatting http:\/\/wp.me\/p1nF6U-10s  #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,4,8],"tags":[350,205,534,540],"class_list":["post-3872","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","category-scripting","tag-format","tag-modules","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun with Formatting &#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\/3872\/friday-fun-with-formatting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun with Formatting &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"PowerShell is very adept at retrieving all sorts of information from computer systems in your network. Often the data is in a format that is hard to digest at a glance. For example, when you see a value like 1202716672 is that something in MB or GB? What if you need to view that value...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-05-30T15:26:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-08-19T18:33:59+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-300x73.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun with Formatting\",\"datePublished\":\"2014-05-30T15:26:09+00:00\",\"dateModified\":\"2015-08-19T18:33:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/\"},\"wordCount\":443,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/formatfunctions-300x73.png\",\"keywords\":[\"Format\",\"modules\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/\",\"name\":\"Friday Fun with Formatting &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/formatfunctions-300x73.png\",\"datePublished\":\"2014-05-30T15:26:09+00:00\",\"dateModified\":\"2015-08-19T18:33:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/formatfunctions.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/05\\\/formatfunctions.png\",\"width\":1324,\"height\":325},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3872\\\/friday-fun-with-formatting\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun with Formatting\"}]},{\"@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 with Formatting &#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\/3872\/friday-fun-with-formatting\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun with Formatting &#8226; The Lonely Administrator","og_description":"PowerShell is very adept at retrieving all sorts of information from computer systems in your network. Often the data is in a format that is hard to digest at a glance. For example, when you see a value like 1202716672 is that something in MB or GB? What if you need to view that value...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-05-30T15:26:09+00:00","article_modified_time":"2015-08-19T18:33:59+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-300x73.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun with Formatting","datePublished":"2014-05-30T15:26:09+00:00","dateModified":"2015-08-19T18:33:59+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/"},"wordCount":443,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-300x73.png","keywords":["Format","modules","PowerShell","Scripting"],"articleSection":["Friday Fun","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/","name":"Friday Fun with Formatting &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-300x73.png","datePublished":"2014-05-30T15:26:09+00:00","dateModified":"2015-08-19T18:33:59+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions.png","width":1324,"height":325},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun with Formatting"}]},{"@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":3744,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3744\/friday-fun-find-file-locking-process-with-powershell\/","url_meta":{"origin":3872,"position":0},"title":"Friday Fun: Find File Locking Process with PowerShell","author":"Jeffery Hicks","date":"March 14, 2014","format":false,"excerpt":"I was asked on Twitter this morning about a way to find out what process has a lock on a given file. I'm not aware of any PowerShell cmdlet that can do that but I figured there had to be a .NET way and if I could find a code\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"handle","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/03\/handle-300x90.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3774,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3774\/friday-fun-create-all-powershell-profile-scripts\/","url_meta":{"origin":3872,"position":1},"title":"Friday Fun: Create All PowerShell Profile Scripts","author":"Jeffery Hicks","date":"March 28, 2014","format":false,"excerpt":"Whenever I train on PowerShell I inevitably get around to discussing PowerShell profile scripts. For those of you new to PowerShell, a profile script is where you put all the commands you want to run that will define your PowerShell session just the way you need it. You might load\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.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1185,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1185\/friday-fun-get-messagebox\/","url_meta":{"origin":3872,"position":2},"title":"Friday Fun Get MessageBox","author":"Jeffery Hicks","date":"March 4, 2011","format":false,"excerpt":"Today's Friday Fun offers a way for you to graphically interact with your PowerShell scripts and functions without resorting to a lot of complex Winform scripting. I have a function that you can use to display an interactive message box complete with buttons like Yes, No or Cancel. You can\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/03\/msgbox.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2306,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2306\/powershell-scripting-with-validatenotnullorempty\/","url_meta":{"origin":3872,"position":3},"title":"PowerShell Scripting with [ValidateNotNullorEmpty]","author":"Jeffery Hicks","date":"May 15, 2012","format":false,"excerpt":"I've been writing about the different parameter validation attributes that you can use in your PowerShell scripting. One that I use in practically every script is [ValidateNotNullorEmpty()]. This validation will ensure that something is passed as a parameter value. I'm not talking about making a parameter mandatory; only that if\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/validatenotnullorempty-300x141.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3627,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3627\/friday-fun-with-rest-regex-and-replacements\/","url_meta":{"origin":3872,"position":4},"title":"Friday Fun with REST, Regex and Replacements","author":"Jeffery Hicks","date":"January 24, 2014","format":false,"excerpt":"I just love using the web cmdlets that were introduced in PowerShell 3.0. One of the cmdlets I use the most is Invoke-RESTMethod. This isn't because I'm dealing with sites that offer REST-ful services, but rather I like that the cmdlet does all the heavy lifting for me when I\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"computereye","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/computereye-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":8871,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8871\/more-colorful-fun-with-powershell\/","url_meta":{"origin":3872,"position":5},"title":"More Colorful Fun with PowerShell","author":"Jeffery Hicks","date":"February 14, 2022","format":false,"excerpt":"In my last Friday Fun post, I shared some PowerShell code for displaying [System.Drawing.Color] values from a console using ANSI escape sequences. After I published the article, I realized what I really wanted was a color palette display that wouldn't be affected by the console background. A Windows Presentation Foundation\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\/2022\/02\/textbox-background.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3872","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=3872"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3872\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}