Pete Long
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;
Can someone edit it, to sort the results in descending order of size? (worst offender a the top for example).
Regards,
Pete
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
}
Can someone edit it, to sort the results in descending order of size? (worst offender a the top for example).
Regards,
Pete
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got exactly what I needed thanQ
Pete