Скрипт вычисляет место в расшаренных папках ( \\share-pc\share\dir1\ ....)
Формат данных в источнике:
Script
cls$dir = 'C:\Temp\'
$sourceFile='folders.csv' # import cvs-file
$destFile='result.csv' # export cvs-file
$Csv = Import-Csv $dir$sourceFile
$dest=$dir+$destFile
$prj_sec = 0
$row = 0
if (Test-Path -Path $dest)
{
Remove-Item $dest
}
foreach ($folder in $Csv.DropLocation) {
$sec=0
$row = $row + 1
$check = 0
$time_text= Get-Date -Format 'HH:mm:ss'
$check = (Test-Path -Path "\\$folder" )
write-host ' |' $row '| ' -nonewline
if ($check) { write-host \\$folder -nonewline }
else { write-host \\$folder -nonewline -foregroundcolor gray } # folder not exist
if ($check)
{
$sec=(measure-command {
$items = (Get-ChildItem "\\$folder" -recurse | Measure-Object -property length -sum)
"$folder; {0:N2}" -f ($items.sum / 1MB) | Out-File $dest -append
}).totalseconds
}
$sec_f= "{0:N2}" -f $sec
if ($check)
{
$space = $items.sum / 1024 / 1024
$space_f= "{0:N2}" -f $space
write-host ' | ' -NoNewline
write-host $space_f 'mb' -NoNewline -foregroundcolor green
write-host ' | ' -NoNewline
write-host $sec_f -NoNewline -foregroundcolor red
write-host ' | '
}
else { write-host ' ' }
$prj_sec += $sec
}
$prj_sec = "{0:N2}" -f $prj_sec
write-host
write-host 'Processing Time: ' -nonewline
write-host $prj_sec -nonewline -foregroundcolor Red
write-host ' sec.'
Комментариев нет:
Отправить комментарий