
{"id":1344,"date":"2015-03-06T17:49:09","date_gmt":"2015-03-06T17:49:09","guid":{"rendered":"http:\/\/tech-no.104.210.61.21.xip.io\/?p=1344"},"modified":"2015-03-06T18:19:47","modified_gmt":"2015-03-06T18:19:47","slug":"quickly-determine-the-largest-folders-on-your-computer-using-powershell","status":"publish","type":"post","link":"https:\/\/tech-no.org\/?p=1344","title":{"rendered":"Quickly determine the largest folders on your computer using powershell"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Need to determine where your disk space went?<\/p>\n<p>copy the following into a file named files.ps1<\/p>\n<p>create a new folder named scripts and save this file in that folder (c:\\scripts\\files.ps1)<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<blockquote><p># Loops through each directory recursively in the current directory and lists its size.<br \/>\n# Children nodes of parents are tabbed<\/p>\n<p>function getSizeOfFolders($Parent, $TabIndex) {<br \/>\n$Folders = (Get-ChildItem $Parent); # Get the nodes in the current directory<br \/>\nForEach($Folder in $Folders) # For each of the nodes found above<br \/>\n{<br \/>\n# If the node is a directory<br \/>\nif ($folder.getType().name -eq &#8220;DirectoryInfo&#8221;)<br \/>\n{<br \/>\n# Gets the size of the folder<br \/>\n$FolderSize = Get-ChildItem &#8220;$Parent\\$Folder&#8221; -Recurse | Measure-Object -property length -sum -ErrorAction SilentlyContinue;<br \/>\n# The amount of tabbing at the start of a string<br \/>\n$Tab = &#8221; &#8221; * $TabIndex;<br \/>\n# String to write to stdout<br \/>\n$Tab + &#8221; &#8221; + $Folder.Name + &#8221; &#8221; + (&#8220;{0:N2}&#8221; -f ($FolderSize.Sum \/ 1mb));<br \/>\n# Check that this node doesn&#8217;t have children (Call this function recursively)<br \/>\ngetSizeOfFolders $Folder.FullName ($TabIndex + 1);<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p># First call of the function (starts in the current directory)<br \/>\ngetSizeOfFolders &#8220;.&#8221; 0<\/p><\/blockquote>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>Now open an elevated powershell window (run as adminstrator)<\/p>\n<p>and type the following:<\/p>\n<p>c:\\scripts\\files.ps1 &gt; c:\\scripts\\output.txt<\/p>\n<p>it will run for a bit and the result will be similar to this output:<\/p>\n<p><a href=\"http:\/\/tech-no.104.210.61.21.xip.io\/?attachment_id=1349\" rel=\"attachment wp-att-1349\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1349\" src=\"http:\/\/tech-no.104.210.61.21.xip.io\/wp-content\/uploads\/sites\/4\/2015\/03\/output.png\" alt=\"output\" width=\"507\" height=\"627\" srcset=\"https:\/\/tech-no.org\/wp-content\/uploads\/sites\/4\/2015\/03\/output.png 507w, https:\/\/tech-no.org\/wp-content\/uploads\/sites\/4\/2015\/03\/output-243x300.png 243w, https:\/\/tech-no.org\/wp-content\/uploads\/sites\/4\/2015\/03\/output-61x75.png 61w, https:\/\/tech-no.org\/wp-content\/uploads\/sites\/4\/2015\/03\/output-101x125.png 101w\" sizes=\"(max-width: 507px) 100vw, 507px\" \/><\/a><\/p>\n<p>the numbers are in MB and the indented (tabbed) data represents sub folders (with the size next to the foldername)<\/p>\n<p>&nbsp;<\/p>\n<p>hope someone finds this helpful<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Need to determine where your disk space went? copy the following into a file named files.ps1 create a new folder named scripts and save this file in that folder (c:\\scripts\\files.ps1) &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- # Loops through each directory recursively in the current directory and lists its size. # Children nodes of parents are tabbed function getSizeOfFolders($Parent, &hellip;<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts\/1344"}],"collection":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1344"}],"version-history":[{"count":3,"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts\/1344\/revisions"}],"predecessor-version":[{"id":1350,"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts\/1344\/revisions\/1350"}],"wp:attachment":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}