Here is a PowerShell function helpful in populating statistics of sub-folder sizes.
- Create a PS1 file named Get-FolderSize.ps1 with the following contents:
Function Get-FolderSize
{
BEGIN{$fso = New-Object -comobject Scripting.FileSystemObject}
PROCESS
{
$path = $input.fullname
$folder = $fso.GetFolder($path)
$size = $folder.size
[PSCustomObject]@{‘Name’ = $path;’Size’ = ($size / 1gb) }
}
}
2. Launch Powershell and import the new PS1 file we create using CMDLET
Import-Module Get-FolderSize.ps1
3. Traverse into the parent folder you wish to query using the CD command.
4. Execute CMDLET
Get-ChildItem -Directory -EA 0 | Get-FolderSize | sort size -Descending
You can now manually consolidate output into an Excel spreadsheet and even calculate totals/average.
