Sorting Recoverable Items Size in Descending Order
Hello,
I have a script modified from various other scripts to match what I need. Check the attached code. I'm trying to Sort Recoverable Items Size by size in Descending order. However I'm not getting results from big to small.
The below script works fine if I sort "Total Item Size (MB)".
It works just fine for me. I tested Exchange 2016 on Windows Server 2012 R2 (PowerShell 4.0) and Exchange 2019 on Windows Server 2019 (PowerShell 5.1).
whatEVOwrx
ASKER
Powershell version 5.1 and I'm connecting to Office365. Hmmm, check below for a Sort compared to one that's not. The 1st image is Sorted and the 2nd is unsorted.
Michael B. Smith
Notice that the first numeric digits are, indeed, sorted.
This is happening because Office 365 is returning those values as _strings_ instead of as numbers.
Look at $mbFolderStats.FolderAndSubfolderSize (gm -i $mbFolderStats.FolderAndSubfolderSize) and see if you can get all values in the same value range (e.g., ToGB(), ToMB(), ToByte() ). If you can, then the sort will then work.
It works just fine for me. I tested Exchange 2016 on Windows Server 2012 R2 (PowerShell 4.0) and Exchange 2019 on Windows Server 2019 (PowerShell 5.1).