Author Posts

February 17, 2016 at 12:58 pm

Evening All, i'm sure this is a really basic issue, but I really cant understand it.

i'm running this

Get-Mailbox | Get-Mailboxstatistics | Where-Object isclutterenabled -eq "False"

I want to see all the users that have isclutterenabled = false, but it only returns the one user that has it enabled or true, even if I change the -eq "False" to -eq "True", I get exactly the same result the one user that has it enabled, please can someone explain what im doing wrong.

Regards Dean

February 17, 2016 at 1:21 pm

I don't have an exchange environment to test, but try this.

Get-Mailbox | Get-Mailboxstatistics | Where-Object {$_.isclutterenabled -eq $False}

February 17, 2016 at 1:24 pm

Yes that worked perfectly, can I ask what yours means, and why mine didn't work, I hate not understanding something.

February 17, 2016 at 1:59 pm

You didn't use the "$_" variable and "{ }" scriptblock. The variable is used to specify the current object in the pipeline and "{ }" specifies the filterscript used by Where-Object cmdlet.

February 17, 2016 at 2:23 pm

Ok I think I get that now, I tried though to use what i've learnt in a different example

Get-Mailbox | Get-Mailboxstatistics | Where-object {$_.displayname -contains "Dean"}
or
Get-Mailbox | Get-Mailboxstatistics | Where-object {$_.displayname -contains "Dean*"}

but neither returns my users called Dean, I get nothing back, confused again???

February 17, 2016 at 4:56 pm

The comparison operator, -contains, is used with arrays or collections. Use –like or –match with your examples.

PS > @(1..10) -contains 5
True
PS > @(1..10) -contains 11
False

Ex: Get-Mailbox | Get-Mailboxstatistics | Where-object {$_.displayname -like "*Dean*"}
Get-Mailbox | Get-Mailboxstatistics | Where-object {$_.displayname –match 'Dean'}

I recommend the following books.
PowerShell TFM 4th Ed
PowerShell In Action 2nd Ed