Listar archivos segun tamaño en PowerShell - format sizes

PHOTO EMBED

Mon Jun 03 2024 14:46:35 GMT+0000 (Coordinated Universal Time)

Saved by @RobertoSilvaZ #powershell #windows11 #system #performance

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
content_copyCOPY