Get-ChildItem -Path C:\ -Recurse -File -ErrorAction SilentlyContinue |
Where-Object { $_.Length -gt 100MB } |
Sort-Object Length -Descending |
Select-Object @{Name='FullName'; Expression={$_.FullName}},
@{Name='Size'; Expression={
if ($_.Length -ge 1GB) {
[math]::Round($_.Length / 1GB, 2) + ' GB'
} elseif ($_.Length -ge 1MB) {
[math]::Round($_.Length / 1MB, 2) + ' MB'
} else {
[math]::Round($_.Length / 1KB, 2) + ' KB'
}
}} |
Format-Table -AutoSize
FullName Size
-------- ----------
C:\some\path\to\largefile1.ext 123.45 MB
C:\another\path\to\largefile2.ext 110.98 MB