コマンド
Get-ChildItem "フォルダのパス" -File -Recurse | Sort-Object -Property Length | Select-Object -Last 1 | Format-Table FullName,Length
結果
FullName Length
-------- ------
E:\download\ffxvbench_installer.zip 3925157987
ファイルサイズのトップ3
スクリプト
$path = "e:\";
$disk_size = Get-PSDrive $path[0] | % { $_.Used + $_.Free }
$cnt = 1
Get-ChildItem $path -File -Recurse | Sort-Object -Property Length -Descending | Select-Object -First 3 FullName, Length | % {
$obj = New-Object PSCustomObject
$obj | Add-Member Rank ($cnt++)
$obj | Add-Member FullName $_.FullName
$obj | Add-Member Length ($_.Length / (1024*1024*1024)).ToString("0.0GB")
$obj | Add-Member Occupancy ($_.Length / $disk_size).ToString("0.0%")
$obj
} | Format-Table Rank, FullName, Length, Occupancy -AutoSize
結果
Rank FullName Length Occupancy
---- -------- ------ ---------
1 E:\download\ffxvbench_installer.zip 3.7GB 3.1%
2 E:\download\dummy.rar 1.1GB 1.0%
3 E:\download\foobar.zip 1.1GB 0.9%
コメント