{"id":4449,"date":"2015-07-15T11:56:19","date_gmt":"2015-07-15T15:56:19","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4449"},"modified":"2015-07-22T14:56:30","modified_gmt":"2015-07-22T18:56:30","slug":"measure-that-folder-with-powershell-revisited","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/","title":{"rendered":"Measure that Folder with PowerShell Revisited"},"content":{"rendered":"<p>Last year <a title=\"read the original post\" href=\"http:\/\/jdhitsolutions.com\/blog\/scripting\/3715\/friday-fun-the-measure-of-a-folder\/\" target=\"_blank\">I posted a PowerShell function<\/a> to measure the size of a folder. I recently had a need to use it again, and realized it needed a few tweaks. By default, the original version recursively searched through all subfolders. But there may be situations where you only want to measure the top level folder, so I added a \u2013NoRecurse parameter. I also added a parameter to display an average value as well.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat1.png\" alt=\"\" \/><br \/>\n<span style=\"color: #44546a; font-size: 9pt;\"><em>Figure 1 Measuring the Temp folder in GB<br \/>\n<\/em><\/span><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat2.png\" alt=\"\" \/><br \/>\n<span style=\"color: #44546a; font-size: 9pt;\"><em>Figure 2 Measuring my Documents folder including average size in KB<br \/>\n<\/em><\/span><\/p>\n<p>Here is the updated function:<\/p>\n<pre class=\"lang:ps decode:true \">Function 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\nCalculate 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.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.080078125\r\nC:\\scripts\\Workflow      Workflow         64 1253.0185546875\r\nC:\\scripts\\modhelp       modhelp           1  386.4970703125\r\nC:\\scripts\\stuff         stuff             4       309.09375\r\nC:\\scripts\\ADTFM-Scripts ADTFM-Scripts    76  297.7880859375\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\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.\r\n.NOTES\r\nLast Updated: July 13, 2015\r\nVersion     : 2.0\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=\"CgcDfHjq87\"><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=EDwZCyx3mR#?secret=CgcDfHjq87\" data-secret=\"CgcDfHjq87\" 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)\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} #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    Switch ($Unit) {\r\n\r\n    \"bytes\" { \r\n                $propHash.Add(\"Size\",$stats.sum)       \r\n                if ($average) {\r\n                    $propHash.Add(\"Avg\",$stats.Average)\r\n                }\r\n                break \r\n            }\r\n    \"kb\"    { \r\n                $propHash.Add(\"SizeKB\",$stats.sum\/1KB) \r\n                if ($average) {\r\n                    $propHash.Add(\"AvgKB\",$stats.Average\/1KB)\r\n                }\r\n                break \r\n            }\r\n    \"mb\"    { \r\n                $propHash.Add(\"SizeMB\",$stats.sum\/1MB)\r\n                if ($average) {\r\n                    $propHash.Add(\"AvgMB\",$stats.Average\/1MB)\r\n                }\r\n                break\r\n            }\r\n    \"gb\"    { \r\n                $propHash.Add(\"SizeGB\",$stats.sum\/1GB)\r\n                if ($average) {\r\n                    $propHash.Add(\"AvgGB\",$stats.Average\/1GB)\r\n                }\r\n                break\r\n            }\r\n    \"tb\"    { \r\n                $propHash.Add(\"SizeTB\",$stats.sum\/1TB)\r\n                if ($average) {\r\n                    $propHash.Add(\"AvgTB\",$stats.Average\/1TB)\r\n                }\r\n                break\r\n            }\r\n    \"pb\"    { \r\n                $propHash.Add(\"SizePB\",$stats.sum\/1PB)\r\n                if ($average) {\r\n                    $propHash.Add(\"AvgPB\",$stats.Average\/1PB)\r\n                } \r\n                break\r\n            }\r\n\r\n    } #switch\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>I hope you'll let me know what you think or what additional features would be helpful.<\/p>\n<p>Update: For an even newer version of this function go <a href=\"http:\/\/bit.ly\/1GDCpqr\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last year I posted a PowerShell function to measure the size of a folder. I recently had a need to use it again, and realized it needed a few tweaks. By default, the original version recursively searched through all subfolders. But there may be situations where you only want to measure the top level folder,&#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 on the blog: Measure that Folder with #PowerShell Revisited","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-4449","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>Measure that Folder with PowerShell Revisited &#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\/4449\/measure-that-folder-with-powershell-revisited\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Measure that Folder with PowerShell Revisited &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Last year I posted a PowerShell function to measure the size of a folder. I recently had a need to use it again, and realized it needed a few tweaks. By default, the original version recursively searched through all subfolders. But there may be situations where you only want to measure the top level folder,...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-15T15:56:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-07-22T18:56:30+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat1.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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Measure that Folder with PowerShell Revisited\",\"datePublished\":\"2015-07-15T15:56:19+00:00\",\"dateModified\":\"2015-07-22T18:56:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/\"},\"wordCount\":129,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/071315_1556_Measurethat1.png\",\"keywords\":[\"Measure-Object\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/\",\"name\":\"Measure that Folder with PowerShell Revisited &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/071315_1556_Measurethat1.png\",\"datePublished\":\"2015-07-15T15:56:19+00:00\",\"dateModified\":\"2015-07-22T18:56:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/071315_1556_Measurethat1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/071315_1556_Measurethat1.png\",\"width\":619,\"height\":106},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4449\\\/measure-that-folder-with-powershell-revisited\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Measure that Folder with PowerShell Revisited\"}]},{\"@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":"Measure that Folder with PowerShell Revisited &#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\/4449\/measure-that-folder-with-powershell-revisited\/","og_locale":"en_US","og_type":"article","og_title":"Measure that Folder with PowerShell Revisited &#8226; The Lonely Administrator","og_description":"Last year I posted a PowerShell function to measure the size of a folder. I recently had a need to use it again, and realized it needed a few tweaks. By default, the original version recursively searched through all subfolders. But there may be situations where you only want to measure the top level folder,...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-07-15T15:56:19+00:00","article_modified_time":"2015-07-22T18:56:30+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat1.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Measure that Folder with PowerShell Revisited","datePublished":"2015-07-15T15:56:19+00:00","dateModified":"2015-07-22T18:56:30+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/"},"wordCount":129,"commentCount":7,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat1.png","keywords":["Measure-Object","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/","name":"Measure that Folder with PowerShell Revisited &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat1.png","datePublished":"2015-07-15T15:56:19+00:00","dateModified":"2015-07-22T18:56:30+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/071315_1556_Measurethat1.png","width":619,"height":106},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4449\/measure-that-folder-with-powershell-revisited\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Measure that Folder with PowerShell Revisited"}]},{"@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":4465,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4465\/measuring-folders-with-powershell-one-more-time\/","url_meta":{"origin":4449,"position":0},"title":"Measuring Folders with PowerShell One More Time","author":"Jeffery Hicks","date":"July 22, 2015","format":false,"excerpt":"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\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3715,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3715\/friday-fun-the-measure-of-a-folder\/","url_meta":{"origin":4449,"position":1},"title":"Friday Fun: The Measure of a Folder","author":"Jeffery Hicks","date":"February 21, 2014","format":false,"excerpt":"Last week, I demonstrated how to measure a file with PowerShell. This week let's go a step further and measure a folder. I'm going to continue to use Measure-Object although this time I will need to use it to measure numeric property values. Here's the complete function after which I'll\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"ruler","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/ruler-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3014,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3014\/getting-top-level-folder-report-in-powershell\/","url_meta":{"origin":4449,"position":2},"title":"Getting Top Level Folder Report in PowerShell","author":"Jeffery Hicks","date":"May 9, 2013","format":false,"excerpt":"One of the sessions I presented recently at TechDays San Francisco was on file share management with PowerShell. One of the scripts I demonstrated was for a function to get information for top level folders. This is the type of thing that could be handy to run say against the\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"foldersize","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/foldersize-1024x589.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/foldersize-1024x589.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/foldersize-1024x589.png?resize=525%2C300 1.5x"},"classes":[]},{"id":7317,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7317\/fast-folder-sizes-with-powershell\/","url_meta":{"origin":4449,"position":3},"title":"Fast Folder Sizes with PowerShell","author":"Jeffery Hicks","date":"February 25, 2020","format":false,"excerpt":"I am always looking for ways to do things faster and easier with PowerShell. One common task that I never seem to stop needing is discovering how much disk space a given folder is consuming. Even though disk space is cheap these days, I guess I'm old-school enough to want\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/getfoldersize3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/getfoldersize3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/getfoldersize3.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/getfoldersize3.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/getfoldersize3.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/getfoldersize3.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":2330,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2330\/friday-fun-get-latest-powershell-scripts\/","url_meta":{"origin":4449,"position":4},"title":"Friday Fun: Get Latest PowerShell Scripts","author":"Jeffery Hicks","date":"May 18, 2012","format":false,"excerpt":"Probably like many of you I keep almost all of my scripts in a single location. I'm also usually working on multiple items at the same time. Some times I have difficult remembering the name of a script I might have been working on a few days ago that 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":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/get-latestscript-300x133.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6465,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6465\/keeping-git-in-check-with-powershell\/","url_meta":{"origin":4449,"position":5},"title":"Keeping Git in Check with PowerShell","author":"Jeffery Hicks","date":"January 28, 2019","format":false,"excerpt":"Last week on Twitter I saw a discussion about a git related problem. The short version of the story is that the person was running out of disk space and didn't understand why. Turns out this person has several development projects using git. All of the change tracking and other\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4449","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=4449"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4449\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}