使用powershell 自訂funciton後就可以使用了.
自訂function 內容
function du ($path = '.\', $unit="MB", $round=0)
{
get-childitem $path -force | ? {
$_.Attributes -like '*Directory*' } | %{
dir $_.FullName -rec -force |
measure-object -sum -prop Length |
add-member -name Path -value $_.Fullname -member NoteProperty -pass |
select Path,Count,@{ expr={[math]::Round($_.Sum/"1$unit",$round)}; Name="Size($unit)"}
}
}
1. 將上述function 貼到畫面, 讓powershell 認得自訂的程式使用方法:
2. 直接執行以下指令, 就可以顯示容量使用前10名的目錄, 而不需要安裝程式.
指令: du .\ –unit MB |select -first 10
ref:
留言