Question : which folder is growing

Hello,

A server's C drive is getting full and i do not know which folder it is. Is there a powershell command out there that tells me which one it is?

tacobell2000

Answer : which folder is growing

Here is a solution that include folder size and folder size with the size of its subfolders. In line 28 changing "size" to "fullsize" at sort-object you can choose to sort by the total subfolder size.
In the same row I set 100 as the maximum number of results at select-object. You can also adjust it according to your needs.
This code runs on my laptop for about 4 minutes for the root of C drive, so be patient.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
Write-Host "$(get-date) Collecting file information..." -ForegroundColor Green
$sh = @{}

Get-ChildItem c:\ee -Recurse -Force -ErrorAction SilentlyContinue | ?{$_.directory} | 
	%{
		if($sh.($_.directory.fullname)){
			$sh.($_.directory.fullname).size+=$_.length
			$sh.($_.directory.fullname).fullsize+=$_.length
		}
		else{$sh.($_.directory.fullname) = @{size = $_.length; fullsize = $_.length}}
	}

Write-Host "$(get-date) Calculating subfolder size information..." -ForegroundColor Green	
$ofs="\"
$sh.keys | %{
	$dirs = $_ -split "\\"
	$curr = $_
	0..($dirs.Count-2) | %{"$($dirs[0..$_])"} | %{if($_[-1] -eq ":"){$_+"\"}else{$_}} | 
		%{
			if($sh.$_) {
				$sh.$_.fullsize += $sh.$curr.size
			}
		}
} 
Write-Host "$(get-date) Emitting results..." -ForegroundColor Green	
$sh.Keys | %{
	New-Object -TypeName PSObject -Property @{name = $_; size = $sh.$_.size; fullsize = $sh.$_.fullsize}
} | Sort-Object size -Descending | select-object -first 100 | ft name, 
		@{n="size (GBs)"; e={$_.size/1gb}; f="n2"}, 
		@{n="size including subfolders (GBs)"; e={$_.fullsize/1gb}; f="n2"}
Random Solutions  
 
programming4us programming4us