{"id":4465,"date":"2015-07-22T14:45:30","date_gmt":"2015-07-22T18:45:30","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4465"},"modified":"2015-07-22T14:50:02","modified_gmt":"2015-07-22T18:50:02","slug":"measuring-folders-with-powershell-one-more-time","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/","title":{"rendered":"Measuring Folders with PowerShell One More Time"},"content":{"rendered":"<p>I know I just <a href=\"http:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/\" target=\"_blank\">posted an update<\/a> to my Measure-Folder function but I couldn't help myself and now I have an update to the update. Part of the update came as the result of a comment asking about formatting results to a certain number of decimal places. I typically the Round() method from the Math .NET class.<\/p>\n<pre class=\"lang:batch decode:true \">PS C:\\&gt; [math]::Round(1234.56789,2)\r\n1234.57\r\nPS C:\\&gt; [math]::Round(1234.5678900123,4)\r\n1234.5679<\/pre>\n<p>So I added a parameter, Round, to automatically round to a certain number of decimal points. The default is 2 but you can enter any value between 0 and 10. If you use 0 the effect is to treat the value as an integer.<\/p>\n<p>The other change I made was to simplify the code. My intention when creating a PowerShell tool is not have duplicate commands, or commands that are very, very similar. In last week's version I used a Switch statement to dynamically create properties and values. But each item was practically the same except for the unit of measurement. So instead I came up with a hash table of units.<\/p>\n<pre class=\"lang:ps decode:true \">$unitHash = @{\r\n  Bytes = 1\r\n  KB = 1KB\r\n  MB = 1MB\r\n  GB = 1GB\r\n  TB = 1TB\r\n  PB = 1PB\r\n}<\/pre>\n<p>With this I can use the hashtable key as the part of property name, and the value for formatting the result.<\/p>\n<pre><code>$value = [Math]::Round($stats.sum\/$UnitHash.item($unit),$Round)<\/code><\/pre>\n<p>The property name is created on the fly for anything other than the default \"bytes\".<\/p>\n<pre class=\"lang:ps decode:true \">$Label = \"Size\"\r\nif ($unit -ne 'bytes') {\r\n  $label+= $($unit.ToUpper())\r\n}\r\n$propHash.Add($label,$value)<\/pre>\n<p>I use the same process if the user wants the average. Here's the complete revised function.<\/p>\n<pre class=\"lang:ps decode:true \">#requires -version 4.0\r\n\r\nFunction Measure-Folder {\r\n\r\n&lt;#\r\n.SYNOPSIS\r\nMeasure the size of a folder.\r\n\r\n.DESCRIPTION\r\nThis command will take a file path and create a custom measurement object that shows the number of files and the total size. The default size will be in bytes but you can specify a different unit of measurement. The command will format the result accordingly and dynamically change the property name as well.\r\n\r\n.PARAMETER Path\r\nThe default is the current path. The command will fail if it is not a FileSystem path.\r\n\r\n.PARAMETER Average\r\nGet the average file size. This will be formatted with the same unit as the total size.\r\n\r\n.PARAMETER NoRecurse\r\nThe default behavior is to recurse through all subfolders. But you can suppress that by using -NoRecurse.\r\n\r\n.PARAMETER Unit\r\nThe default unit of measurement is bytes, but you can use any of the standard PowerShell numeric shortcuts: \"KB\",\"MB\",\"GB\",\"TB\",\"PB\"\r\n\r\n.PARAMETER Round\r\nThe number of decimal points to round the sum and average values. The default is 2. Use a value of 10 to not round. The maximum value is 10.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; measure-folder c:\\scripts \r\n\r\nPath            Name         Count         Size\r\n----            ----         -----         ----\r\nC:\\scripts      scripts       2858     43800390\r\n\r\nMeasure the scripts folder using the default size of bytes.\r\n\r\n.EXAMPLE\r\n\r\nPS C:\\&gt; dir c:\\scripts -Directory | measure-folder -Unit kb | Sort Size* -Descending | Select -first 5 | format-table -AutoSize\r\n\r\nPath                     Name          Count          SizeKB\r\n----                     ----          -----          ------\r\nC:\\scripts\\GP            GP               40         2287.08\r\nC:\\scripts\\Workflow      Workflow         64         1253.02\r\nC:\\scripts\\modhelp       modhelp           1          386.49\r\nC:\\scripts\\stuff         stuff             4          309.09\r\nC:\\scripts\\ADTFM-Scripts ADTFM-Scripts    76          297.78\r\n\r\nGet all the child folders under C:\\scripts, measuring the size in KB. Sort the results on the size property in descending order. Then select the first 5 objects and format the results as a table.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; measure-folder $env:temp -Average -unit MB -round 10\r\n\r\nPath   : C:\\Users\\Jeff\\AppData\\Local\\Temp\r\nName   : Temp\r\nCount  : 64626\r\nSizeMB : 6769.94603252411\r\nAvgMB  : 0.104755764437287\r\n\r\nMeasure all the %TEMP% folder, including a file average all formatted in MB with no rounding\r\n.NOTES\r\nLast Updated: July 22, 2015\r\nVersion     : 2.2\r\n\r\nOriginally published at http:\/\/jdhitsolutions.com\/blog\/scripting\/3715\/friday-fun-the-measure-of-a-folder\/\r\n\r\nLearn more about PowerShell:\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"4rwyIksO3a\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/\">Essential PowerShell Learning Resources<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Essential PowerShell Learning Resources&#8221; &#8212; The Lonely Administrator\" src=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/embed\/#?secret=F4GMlhraPA#?secret=4rwyIksO3a\" data-secret=\"4rwyIksO3a\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\r\n\r\n\r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n  \r\n\r\n.LINK\r\nGet-ChildItem\r\nMeasure-Object\r\n\r\n.INPUTS\r\nstring or directory\r\n\r\n.OUTPUTS\r\nCustom object\r\n#&gt;\r\n[cmdletbinding()]\r\n\r\nParam(\r\n[Parameter(Position=0,ValueFromPipeline=$True,\r\nValueFromPipelineByPropertyName=$True)]\r\n[ValidateScript({\r\nif (Test-Path $_) {\r\n   $True\r\n}\r\nelse {\r\n   Throw \"Cannot validate path $_\"\r\n}\r\n})]\r\n[Alias(\"fullname\")]\r\n[string]$Path = \".\",\r\n[switch]$NoRecurse,\r\n[Alias(\"avg\")]\r\n[switch]$Average,\r\n[ValidateSet(\"bytes\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\")]\r\n[string]$Unit = \"bytes\",\r\n[ValidateRange(0,10)]\r\n[int]$Round = 2\r\n)\r\n\r\nBegin {\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n\r\n    #hash table of parameters to Splat to Get-ChildItem\r\n    $dirHash = @{\r\n     File = $True\r\n     Recurse = $True\r\n    }\r\n    if ($NoRecurse) {\r\n        Write-Verbose \"No recurse\"\r\n        $dirHash.remove(\"recurse\")\r\n    }\r\n\r\n    #hash table of parameters to splat to measure-Object\r\n    $measureHash = @{\r\n        Property = \"length\"\r\n        Sum = $True\r\n    }\r\n    if ($Average) {\r\n        Write-Verbose \"Including Average\"\r\n        $measureHash.Add(\"Average\",$True)\r\n    }\r\n    Write-Verbose \"Rounding to $Round decimal points.\"\r\n} #begin\r\n\r\nProcess {\r\n    $Resolved = Resolve-Path -Path $path\r\n    $Name = Split-Path -Path $Resolved -Leaf\r\n\r\n    #verify we are in the file system\r\n    if ($Resolved.Provider.Name -eq 'FileSystem') {\r\n\r\n    #define a hash table to hold new object properties\r\n    $propHash = [ordered]@{\r\n      Path=$Resolved.Path\r\n      Name=$Name\r\n    }\r\n\r\n    Write-Verbose \"Measuring $resolved in $unit\"\r\n\r\n    $dirHash.Path = $Resolved\r\n\r\n    $stats = Get-ChildItem @dirHash | Measure-Object @measureHash\r\n\r\n    Write-Verbose \"Measured $($stats.count) files\"\r\n\r\n    $propHash.Add(\"Count\",$stats.count)\r\n    $unitHash = @{\r\n         Bytes = 1\r\n         KB = 1KB\r\n         MB = 1MB\r\n         GB = 1GB\r\n         TB = 1TB\r\n         PB = 1PB\r\n     }\r\n\r\n     $value = [Math]::Round($stats.sum\/$UnitHash.item($unit),$Round)\r\n\r\n     $Label = \"Size\"\r\n     if ($unit -ne 'bytes') {\r\n        $label+= $($unit.ToUpper())\r\n     }\r\n\r\n    $propHash.Add($label,$value)\r\n    #repeat process for Average\r\n    if ($Average) {\r\n        $value = [Math]::Round($stats.average\/$UnitHash.item($unit),$Round)\r\n         $Label = \"Avg\"\r\n        if ($unit -ne 'bytes') {\r\n            $label+= $($unit.ToUpper())\r\n        }\r\n        $propHash.Add($label,$value)\r\n    } #if Average\r\n\r\n    #write the new object to the pipeline\r\n    New-Object -TypeName PSobject -Property $propHash\r\n\r\n    }\r\n    else {\r\n        Write-Warning \"You must specify a file system path.\"\r\n    }\r\n\r\n} #process\r\n\r\nEnd {\r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n} #end function<\/pre>\n<p>The results are the same, with the addition of the rounding option.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/072215_1845_MeasuringFo1.png\" alt=\"\" \/><\/p>\n<p>I swear this is the last change. Unless someone gives me a cool idea! Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I know I just posted an update to my Measure-Folder function but I couldn&#8217;t help myself and now I have an update to the update. Part of the update came as the result of a comment asking about formatting results to a certain number of decimal places. I typically the Round() method from the Math&#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":"Just Posted: Measuring Folders with #PowerShell One More Time","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":[4,8],"tags":[178,534,540],"class_list":["post-4465","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-measure-object","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>Measuring Folders with PowerShell One More Time &#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\/4465\/measuring-folders-with-powershell-one-more-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Measuring Folders with PowerShell One More Time &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I know I just posted an update to my Measure-Folder function but I couldn&#039;t help myself and now I have an update to the update. Part of the update came as the result of a comment asking about formatting results to a certain number of decimal places. I typically the Round() method from the Math...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-22T18:45:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-07-22T18:50:02+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/072215_1845_MeasuringFo1.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Measuring Folders with PowerShell One More Time\",\"datePublished\":\"2015-07-22T18:45:30+00:00\",\"dateModified\":\"2015-07-22T18:50:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/\"},\"wordCount\":254,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/072215_1845_MeasuringFo1.png\",\"keywords\":[\"Measure-Object\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/\",\"name\":\"Measuring Folders with PowerShell One More Time &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/072215_1845_MeasuringFo1.png\",\"datePublished\":\"2015-07-22T18:45:30+00:00\",\"dateModified\":\"2015-07-22T18:50:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/072215_1845_MeasuringFo1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/072215_1845_MeasuringFo1.png\",\"width\":794,\"height\":210},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4465\\\/measuring-folders-with-powershell-one-more-time\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Measuring Folders with PowerShell One More Time\"}]},{\"@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":"Measuring Folders with PowerShell One More Time &#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\/4465\/measuring-folders-with-powershell-one-more-time\/","og_locale":"en_US","og_type":"article","og_title":"Measuring Folders with PowerShell One More Time &#8226; The Lonely Administrator","og_description":"I know I just posted an update to my Measure-Folder function but I couldn't help myself and now I have an update to the update. Part of the update came as the result of a comment asking about formatting results to a certain number of decimal places. I typically the Round() method from the Math...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-07-22T18:45:30+00:00","article_modified_time":"2015-07-22T18:50:02+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/072215_1845_MeasuringFo1.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Measuring Folders with PowerShell One More Time","datePublished":"2015-07-22T18:45:30+00:00","dateModified":"2015-07-22T18:50:02+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/"},"wordCount":254,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/072215_1845_MeasuringFo1.png","keywords":["Measure-Object","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/","name":"Measuring Folders with PowerShell One More Time &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/072215_1845_MeasuringFo1.png","datePublished":"2015-07-22T18:45:30+00:00","dateModified":"2015-07-22T18:50:02+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/072215_1845_MeasuringFo1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/072215_1845_MeasuringFo1.png","width":794,"height":210},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Measuring Folders with PowerShell One More Time"}]},{"@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":8934,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8934\/metric-meta-powershell-scripting\/","url_meta":{"origin":4465,"position":0},"title":"Metric Meta PowerShell Scripting","author":"Jeffery Hicks","date":"March 1, 2022","format":false,"excerpt":"I was fiddling around with PowerShell the other day. I spend my day in front of a PowerShell prompt and am always looking for ways to solve problems or answer questions without taking my hands off the keyboard. For some reason, I started thinking about metric conversions. How many feet\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\/03\/l2qt.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/l2qt.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/l2qt.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/l2qt.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":3872,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3872\/friday-fun-with-formatting\/","url_meta":{"origin":4465,"position":1},"title":"Friday Fun with Formatting","author":"Jeffery Hicks","date":"May 30, 2014","format":false,"excerpt":"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\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"formatfunctions","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/formatfunctions-300x73.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":9229,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9229\/exposing-the-mystery-of-powershell-objects\/","url_meta":{"origin":4465,"position":2},"title":"Exposing the Mystery of PowerShell Objects","author":"Jeffery Hicks","date":"March 14, 2023","format":false,"excerpt":"A few weeks ago, I was working on content for a new PowerShell course for Pluralsight. The subject was objects. We all know the importance of working with objects in PowerShell. Hopefully, you also know that the output you get on your screen from running a PowerShell command is not\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\/2023\/03\/2023-03-14_10-19-52.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2023\/03\/2023-03-14_10-19-52.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2023\/03\/2023-03-14_10-19-52.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3893,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3893\/more-powershell-laziness\/","url_meta":{"origin":4465,"position":3},"title":"More PowerShell Laziness","author":"Jeffery Hicks","date":"June 25, 2014","format":false,"excerpt":"A few days ago I posted an article on using Update-TypeData to provide shortcuts to object properties. These shortcuts might save a few keystrokes typing, especially if you use tab completion. They can also give you more meaningful output. But you can take this even further and save yourself even\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"lightbulb-idea","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/06\/lightbulb-idea.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5716,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5716\/adding-efficiency-with-powershell-type-extensions\/","url_meta":{"origin":4465,"position":4},"title":"Adding Efficiency with PowerShell Type Extensions","author":"Jeffery Hicks","date":"October 31, 2017","format":false,"excerpt":"The other day I posted an article about custom properties which wrapped up with a look at Update-TypeData. The goal is not so much to make your scripts or modules easier to use, but rather to increase efficiency at the command prompt. When running commands interactively I want to get\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb-9.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb-9.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb-9.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb-9.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8143,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8143\/solving-the-powershell-memory-challenge\/","url_meta":{"origin":4465,"position":5},"title":"Solving the PowerShell Memory Challenge","author":"Jeffery Hicks","date":"February 8, 2021","format":false,"excerpt":"I hope you tried your hand at this Iron Scripter PowerShell challenge on reporting memory usage. The basic challenge was to find the total percent of working set memory that a specific process or service is using. Here's how I approached it, with my usual disclaimer that my solution is\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\/2021\/02\/get-wspct.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/get-wspct.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/get-wspct.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/get-wspct.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/get-wspct.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/get-wspct.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4465","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=4465"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4465\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}