Get-CsOnlineUser - Cannot filter with boolean attributes due to casting errors

Copper Contributor

Since Friday July 20th 2021, 

 

Every time I run a Get-CsOnlineUser with a Filter on a boolean attribute, I am getting an error. 

 

Example 1: Getting users with Voice Enabled:

 

 

Get-CsOnlineUser -Filter {EnterpriseVoiceEnabled -eq $true}

 

 

 

Example 2: Getting Enabled Users:

 

 

Get-CsOnlineUser -Filter {Enabled -eq $true}

 

 

 

The Response I get is always:

 

 

Get-CsOnlineUser: Cannot bind parameter 'Filter' to the target. Exception setting "Filter": "Unable to cast object of type 'System.Boolean' to type 'System.String'."

 

 

 

Any ideas what could be happening here?

9 Replies

@ckarawani-dev 

 

Just tried and I seem to have the same problem. 

I have the Microsoft Teams Version 2.3.1 module installed. 

 

I started getting this error a couple days ago as well. It was working Thursday or Friday, but is now producing this error.

Exactly!! I was really going crazy, checking if anything changed on our end with our scripts, the version of powershell or the cmdlet. I have opened a ticket with them and waiting for a response. I will update this thread the moment I have an update.
I am having the same issue. have you received any updates yet?

The ticket is still open. Their support resource provided a wrongful suggestion using "$true" as true and "$null" as false. This is not a valid solution as any non-empty string would resolve true.

For now , the two viable workarounds I identified are:

1. Using any non-empty string (ex. 'banana') as true and an empty string '' as false.
Not ideal and a bit of a hack using an empty/non-empty string as my flags.

2. Using Where-Object {$_.EnterpriseVoiceEnabled -eq $true} instead.
Also not ideal as it is way less efficient as it first fetches the non-filtered results to then discard a bunch via the Where-Object.

Still waiting on a better fix.

@ckarawani-dev thank you for the update. making those changes on my scripts worked. 

@ckarawani-dev 

I had the issue for just over a week, I have run my original scripts without the workaround below and the issue appears to be resolved I do NOT receive the error now using filters as below

get-csonlineuser -filter {(Enterprisevoiceenabled -eq $true) -and (enabled -eq $true)}

@jeffkelly  wow! You're right! It is indeed fixed. I'm really not sure what we're supposed to do in the future when these types of issues occur. Opening a service request via the Microsoft 365 admin center (admin.microsoft.com) didn't really help much as they were not really aware of the problem and could not provide any explanation or support around the Microsoft Teams cmdlet.