Hello every one! I have this script:
$log = ".\logfile.log" $startFolder = "C:\VMs" $colItems = Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object foreach ($i in $colItems){ $itemSum = Get-ChildItem ("$startFolder\" + $i.Name) -recurse | Measure-Object -property length -sum"$startFolder\$i -- " + "{0:N2}" -f ($itemSum.sum / 1KB) + " KB" >> $log } import-csv $log -delimiter "`t" | export-csv .\TEST.csv $body = Get-Content $log | Sort | Out-String Send-MailMessage -From test@test.local -To test1@test.local -Subject "Test Theme" -attachment .\TEST.csv -Encoding ([System.Text.Encoding]::UTF8) -Body $body -SmtpServer test123.test.local Remove-Item $log Remove-Item .\TEST.csv
When this script done I receive something like this in email message:
C:\VMs\Backup -- 0,00 KB
C:\VMs\Vbox -- 82 874 750,42 KB
C:\VMs\VMWARE_BACKUP -- 182 818,77 KB
How I can change this script to sort by folder size? Notalphabetically.
Thanks in advance!