Link to home
Start Free TrialLog in
Avatar of Pete Long
Pete LongFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PowerShell Sort Decending?

Hi

I found the following script on the internet that lists all the folders in a given directory and displays the folder size in MB;

$rootPath = "C:\Root-Folder\"
$colItems1 = Get-ChildItem $rootPath
foreach ($i in $colItems1)
{
$colItems = (Get-ChildItem -recurse "$rootPath\$i" | Measure-Object -property length -sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB,$i"
"{0:N2}" -f ($colItems.sum / 1MB) + " MB,$i" >>C:\result.txt
}

Open in new window


Can someone edit it, to sort the results in descending order of size?  (worst offender a the top for example).

Regards,

Pete
SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pete Long

ASKER

Brilliant, Thanks to everyone.

I got exactly what I needed thanQ

Pete