Write-Host DU 1.0 - 統計目錄大小的腳本,作用和linux的du類似。`n $args = "D:/software" if (!$args) {write-host "du 絕對目錄名,如:`ndu.ps1 d:/mp3"} elseif (!(Test-Path $args)) {write-host "錯誤:找不到目標目錄名!"} else # 我在前人基礎上整理,簡化了不必要的功能,效果不錯。個人感覺比sysinternals的du.exe好。 { $b=Get-ChildItem $args -Recurse | Measure-Object -property length -sum write-host "----【$args -- ",("{0:N2}" -f ($b.sum / 1MB)),"MB】----" # 2010-8-15日出爐 $a=Get-ChildItem $args | Where-Object {$_.PsIsContainer -eq $true} foreach ($i in $a) { $subFolderItems = (Get-ChildItem $i.FullName -Recurse | Measure-Object -property length -sum) $i.FullName + " -- " + "{0:N2}" -f ($subFolderItems.sum / 1MB) + " MB" } } pause