I cant get this to work isclutterenabled

This topic contains 5 replies, has 2 voices, and was last updated by  random commandline 2 years, 5 months ago.

  • Author
  • #35378

    Dean Robinson

    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

  • #35379

    random commandline

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

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

    Dean Robinson

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

  • #35382

    random commandline

    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.

  • #35384

    Dean Robinson

    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???

  • #35389

    random commandline

    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

You must be logged in to reply to this topic.