List the subfolder sizes in a folder
1 2 3 4 5 |
Get-ChildItem -force '\\servername\sql_backup\BACKUP_OLA' -ErrorAction SilentlyContinue | Where-Object { $_ -is [io.directoryinfo] } | % { $len = 0 Get-ChildItem -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length } $_.fullname, '{0:N2} GB' -f ($len / 1Gb) } |
Result sample:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/# result \\servername\sql_backup\BACKUP_OLA\SQL102249_STS01AI 15.61 GB \\servername\sql_backup\BACKUP_OLA\SQL102318e002b 718.37 GB \\servername\sql_backup\BACKUP_OLA\SQL102250_STS01BI 22.81 GB \\servername\sql_backup\BACKUP_OLA\SQL102318e001b 94.21 GB \\servername\sql_backup\BACKUP_OLA\SQL102184_STSS50E 97.33 GB \\servername\sql_backup\BACKUP_OLA\SQL102249_STS01AP 17.52 GB \\servername\sql_backup\BACKUP_OLA\SQL102250_STS01BP 36.99 GB \\servername\sql_backup\BACKUP_OLA\SQL102318e003c 355.39 GB \\servername\sql_backup\BACKUP_OLA\SQL102318e004b 3312.04 GB \\servername\sql_backup\BACKUP_OLA\SQL102249_STS05AP 1.85 GB \\servername\sql_backup\BACKUP_OLA\SQL102250_STS05BP 2.39 GB \\servername\sql_backup\BACKUP_OLA\AGSQL102318E005 0.90 GB \\servername\sql_backup\BACKUP_OLA\SQL102185_STSS50P 0.07 GB #/ |