Цитата NickM:
прочитать, понять направление и сделать по своему »
|
Цитата NickM:
модифицировать предложенный сценарий для подкаталогов: »
|
Например:
Код:

$targetfolder='C:\Users'
$dataColl = @()
gci -force $targetfolder -Directory -ErrorAction SilentlyContinue| % {
gci -force $_.fullname -Directory -ErrorAction SilentlyContinue| Where-Object {($_.Name -match "^Desktop$") -or ($_.Name -match "^Downloads$") -or ($_.Name -match "^Videos$")}| % {
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue| % { $len += $_.length }
$filesCount = (gci -recurse -force $_.fullname -File -ErrorAction SilentlyContinue| Measure-Object).Count
$dataObject = New-Object PSObject -Property @{
Folder = $_.fullname
SizeGb = ('{0:N3}' -f ($len / 1Gb)) -as [single]
filesCount=$filesCount
}
$dataColl += $dataObject
}
}
$dataColl| Export-Csv ([Environment]::GetFolderPath("Desktop")+"\outfile.csv") -Delimiter ';' -NoTypeInformation
Код:

"SizeGb";"Folder";"filesCount"
"0";"C:\Users\Default\Desktop";"0"
"0";"C:\Users\Default\Downloads";"0"
"0";"C:\Users\Default\Videos";"0"
"0";"C:\Users\k1r\Desktop";"3"
"0.319";"C:\Users\k1r\Downloads";"443"
"0.002";"C:\Users\k1r\Videos";"5"
"0";"C:\Users\Public\Desktop";"10"
"0";"C:\Users\Public\Downloads";"1"
"0";"C:\Users\Public\Videos";"1"
"0.585";"C:\Users\v17x\Desktop";"123"
"27.589";"C:\Users\v17x\Downloads";"4240"
"2.131";"C:\Users\v17x\Videos";"188"