2024年7月8日 星期一

Using cmd powershell to du sub folders (Get sub folders size) 計算子目錄容量

powershell -command "$fso = new-object -com Scripting.FileSystemObject; gci -Directory -Depth 3 | select @{l='Size'; e={$fso.GetFolder($_.FullName).Size}},FullName | sort Size -Descending | ft @{l='Size [MB]'; e={'{0:N2}    ' -f ($_.Size / 1MB)}},FullName"


powershell -command "$fso = new-object -com Scripting.FileSystemObject; gci -Directory -Depth 2 | select @{l='Size'; e={$fso.GetFolder($_.FullName).Size}},FullName | sort Size -Descending | ft @{l='Size [KB]'; e={'{0:N2}    ' -f ($_.Size / 1KB)}},FullName"


powershell -command "$fso = new-object -com Scripting.FileSystemObject; gci -Directory -Depth 2 | select @{l='Size'; e={$fso.GetFolder($_.FullName).Size}},FullName | sort Size -Descending | ft @{l='Size [KB]'; e={'{0:N2}    ' -f ($_.Size / 1000)}},FullName"



reference:

https://stackoverflow.com/questions/12813826/get-folder-size-from-windows-command-line

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.4


 Get-Content x.log -Wait -Tail 100

沒有留言:

張貼留言