I cant get this to work isclutterenabled

This topic contains 5 replies, has 2 voices, and was last updated by Profile photo of random commandline random commandline 7 months, 1 week ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #35378
    Profile photo of Dean Robinson
    Dean Robinson
    Participant

    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
    Profile photo of random commandline
    random commandline
    Participant

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

    Get-Mailbox | Get-Mailboxstatistics | Where-Object {$_.isclutterenabled -eq $False}
    
    #35380
    Profile photo of Dean Robinson
    Dean Robinson
    Participant

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

    #35382
    Profile photo of random commandline
    random commandline
    Participant

    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
    Profile photo of Dean Robinson
    Dean Robinson
    Participant

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

    #35389
    Profile photo of random commandline
    random commandline
    Participant

    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

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.