question

SenhorDolas-2197 avatar image
0 Votes"
SenhorDolas-2197 asked ·

How to filter on FolderAndSubfolders from Get-exoMailboxFolderStatistics

Hiya
I am trying to filter on mailboxes with FolderAndSubfolders size greater than 300MB and nothigs comes up even thou I am many.

This is the script that I am using


  Get-exoMailbox -ResultSize unlimited |Get-exoMailboxFolderStatistics  -FolderScope RecoverableItems | ?{$_.FolderAndSubfolders -lt 500MB}

Is there a way to make this filter work?
SD


office-exchange-server-administrationwindows-server-powershell
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

michev avatar image
1 Vote"
michev answered ·

There's no property called "FolderAndSubfolders", make sure you use the full name. Also, as this is a string value, you cannot do direct comparison against a value of 500MB, you have to convert it first.

Here's an example that should work:

 Get-MailboxFolderStatistics vasil -FolderScope recover | ? {[double]((($_.FolderAndSubfolderSize).split("("))[1]).Split(" ")[0] -gt "500MB"}
· 7 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @michev - Thanks for the learning tip.
If I do just the folder size calculation, I get this:
But If I filter just on name I get this:
Get-EXOMailbox vasil@vasil.com | Get-exoMailboxFolderStatistics -FolderScope recover | ? {$.name -clike "Reco"}| select name, FolderAndSubfolderSize
Name FolderAndSubfolderSize
Recoverable Items 360.5 MB (377,967,208 bytes)
But I put the 2 Where-Object together I get nothing?
Get-EXOMailbox vasil@vasil.com| Get-exoMailboxFolderStatistics -FolderScope recover | ? ({$
.name -clike "Reco"} -and {[double]((($_.FolderAndSubfolderSize).split("("))[1]).Split(" ")[0] -gt "100MB"} )| select name, FolderAndSubfolderSize
SD

0 Votes 0 ·

There's no need to treat the value of FolderAndSubfolderSize as a string. If you intend to compare the value to a constant such as "100MB" then just use $_.FolderAndSubfolderSize.ToMB().


1 Vote 1 ·

Tried that before - didn't work - thanks for replying @RichMatheisen-8856

0 Votes 0 ·

You have some typos again, $_.Name instead of $.Name, and using the like operator without wildcard. Also your brackets are all over the place. It helps to test the code in parts, you know :)

 Get-EXOMailbox vasil | Get-EXOMailboxFolderStatistics -FolderScope recover | ? {($_.name -clike "Reco*") -and [double]((($_.FolderAndSubfolderSize).split("("))[1]).Split(" ")[0] -gt "100MB" }| select name, FolderAndSubfolderSize 

@RichMatheisen-8856 ideally, but in ExO it's all strings :(

1 Vote 1 ·

@michev

Brilliant and thank you so much....

Having a really bad day and not engaging brain!

Guys Thanks!

That works fine.

0 Votes 0 ·
Show more comments

Doh! Deserialized data. :-(

I wonder, if he's running the script from the EMS shell, if this would work?

 $Bqs = [Microsoft.Exchange.Data.ByteQuantifiedSize]::parse($_.FolderAndSubFolderSize)
0 Votes 0 ·