欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Powershell 之批量獲取文件大小的實(shí)現(xiàn)代碼

 更新時(shí)間:2016年11月27日 20:54:23   投稿:mdxy-dxy  
這篇文章主要介紹了Powershell 之批量獲取文件大小的實(shí)現(xiàn)代碼,需要的朋友可以參考下

效果圖:

核心代碼

$startFolder = "D:\"
$colItems = (Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)
foreach ($i in $colItems)
{
 $subFolderItems = (Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum)
 $FileSize="{0:N2}" -f ($subFolderItems.sum / 1GB)
 $Unit='GB'
 if($FileSize -lt 1)
 {
  $FileSize="{0:N2}" -f ($subFolderItems.sum / 1MB)
  $Unit='MB'
 }
 write-host $i.FullName ' -- ' $FileSize $Unit -fore green
}

注意:如果是第一次運(yùn)行需要開(kāi)啟執(zhí)行腳本權(quán)限。

在powershell中運(yùn)行如下命令,然后 Y 確認(rèn)即可。

開(kāi)啟:set-executionpolicy remotesigned

關(guān)閉:Set-ExecutionPolicy Restricted

相關(guān)文章

最新評(píng)論