I cant get this to work isclutterenabled

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

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

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

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

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.

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”}
Get-Mailbox | Get-Mailboxstatistics | Where-object {$
.displayname -contains “Dean*”}

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

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

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

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