ディレクトリにより、フォルダ容量の計算

来源:互联网 发布:联合程序员开发网 编辑:程序博客网 时间:2024/05/19 19:56
●size.txtの内容
colMode colkey colIsPersonal colcomment
R C:\PStest FALSE 計算


●*.ps1

$file_path = "C:\Users\xxxxxuser\Desktop\powershell\size.txt"
$myarr = Get-Content $file_path
#$myarr
foreach($i in $myarr){
    $row = $i.Replace(" ",",")
    $rowCol = $row.Split(",")
    
    #$rowCol[1]
    if($rowCol[1] -eq "colkey"){   
        write-host $rowCol[1] -foregroundcolor "green"
    }
    else
    {
        #$rowCol[1] = C:\PStest
        $sizePro=Get-ChildItem $rowCol[1] -Recurse | Measure-Object -property length -sum
         write-host ($sizePro.Sum / 1024)  "MB"
        $sizePro
    }

}


0 0
原创粉丝点击