Powershell resultsize not working

2017-12-08T14:28:04+00:00 June 19th, 2014|PowerShell|

Here’s an interesting one I came across today, I wanted to do a get-mailbox with a result size specified and a where clause, something like this:

get-mailbox -resultsize 250 | where-object {$_.emailaddresses -like “*MBX:0*”} | Where-Object {$_.ExchangeUserAccountControl -ne “AccountDisabled”} | measure-object

However it failed with the following error:

WARNING: There are more results available than are currently displayed. To view them, increase the value for the ResultSize parameter.

But when running just the get-mailbox –resultsize 250 on its own it worked fine. To work around this I changed the resultsize to unlimited and told it to get the top 250 results:

get-mailbox -resultsize unlimed | where-object {$_.emailaddresses -like “*MBX:0*”} | Where-Object {$_.ExchangeUserAccountControl -ne “AccountDisabled”} | Select-Object –First 250 | measure-object

Worked like a charm! Hope it helps J