PowerShell Filter command fails

Sometimes what seems an obvious PowerShell filter request is rejected. The parameter you’re seeking is visible when you get-user (Exchange) or get-csUser (Lync), but you’re still rejected.

The error message is the rather bleak and uninspiring:

Invoke-Command : Cannot bind parameter 'Filter' to the target. Exception setting "Filter": ""UMDialPlan" is not a recognized filterable property. For a complete list of filterable properties see the command help.”

But I don’t want to see the command help for a complete list of filterable properties – I want to filter on this parameter!</hissyfit>

The fix is to change your syntax and use “Where-object”, as per this example:


And to save you typing it, here are a couple of versions you can scrape:

Get-User | Where-Object {$_.UMDialPlan -match "<Whatever>"} | ft DisplayName

Get-CsUser | Where-Object {$_.VoicePolicy -match "^5"} | Grant-CsVoicePolicy –PolicyName <Whatever>

Credit to the amazing Lync PowerShell blog for this one.

Added 30Mar2014: This might help your filtering techniques: TechNet “about_Comparison_Operators”


– G.

One Comment

  1. Greig: You basically suggested the following: “Guys, you dont need to understand how -Filter works! Always use the where-object cmdlet instead of the -Filter switch, and everybody will be happy!”

    Let me clarify why this article could have been so much better by explaining the syntax of the “-filter”. If you use -filter, you will only receive the result set, that matches your criteria. Big deal you may say, if we get a bigger result set, we can simply filter them piping via the where-object. Yes thats true, but basically there are 2 problems with WHERE-OBJECT:
    1) simply because the where-object not always works! I dont remember the details, but have seen many PS blogs out there referencing to the fact that some attributes/objects cannot be used. I am not a PS-expert, so cannot clarify better.
    2) if the result set is giant (like you have 100.000 users in a pool), and you only want to return only a few users via searches, the PS must grab all the 100.000 objects and then throw out the 99,99%. Waste of system resources, and if the session is a remote powershell, via a slow link, it will take A LOT more time.

    Unfortunately the -Filter is a not-so-trivial-to-understand bastard. And by the way, the PS beginners will have a hard time understanding why your initial example in the beginning of the post does give syntax error (hint: you didnt actually explain why filter behaves like it does in the example ;) ).

    No criticizing, just I am into this -filter crap, and all the google results lack the answer why I am unable to construct a syntactically correct command to run it. I always get back this “cannot bind” blabla and cannot seem to find the filterable parameters list used in Lync, similar to what I already found for exchange: https://technet.microsoft.com/en-us/library/bb738155%28v=exchg.150%29.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.