OWAEnabled filter returns unexpected results

I recently had a customer that was running:

get-casmailbox -filter {OWAEnabled -eq $false}

In the output they saw numerous rows displayed where OWAEnabled was actually listed as $true.

 

They found that if they run the command below they get the correct result:

get-casmailbox | where-object {$_.owaenabled -eq $false}

 

So why the difference?  The OWAEnabled property is not actually assigned a default value.  When the get-casmailbox cmdlet is run it treats Not Set as $true when it displays the data.  The filter is returning everything that is False and that has not been set previously.

So how do you always get accurate results from the filter?  The only ways are to:

  • explicitly define the value of OWAEnabled with the creation of each mailbox (easy to do if you use provisioning scripts, an extra manual step if you use the GUI)
  • Run this command:
    get-casmailbox | where-object {$_.owaenabled -ne $false} | set-casmailbox -owaenabled $true
    This command will produce warnings for every user it touches, but does not need to change because the user has already been set to $true.

 

Hopefully this helps everyone get accurate results back from this cmdlet.  Have a good weekend!