powershell获取windows子文件夹的大小
2021-06-30 07:06
标签:obj pre rop start style write size file containe powershell获取windows子文件夹的大小 标签:obj pre rop start style write size file containe 原文地址:https://www.cnblogs.com/20e8/p/9994212.html 1 $startFolder = "E:\Migration\"
2 $colItems = (Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)
3 foreach ($i in $colItems)
4 {
5 $subFolderItems = (Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum)
6 $FileSize="{0:N2}" -f ($subFolderItems.sum / 1GB)
7 $Unit=‘GB‘
8 if($FileSize -lt 1)
9 {
10 $FileSize="{0:N2}" -f ($subFolderItems.sum / 1MB)
11 $Unit=‘MB‘
12 }
13 write-host $i.FullName ‘ -- ‘ $FileSize $Unit -fore green
14 }
计算速度很快,只需修改$startFolder变量即可。
文章标题:powershell获取windows子文件夹的大小
文章链接:http://soscw.com/index.php/essay/99740.html