When using PowerShell to pull REST data from MS CRM, escape `$filter !

Note to self.

When trying to filter a REST response in PowerShell, by using the “$filter” parameter in the url (as with MS CRM 2011), you must escape the “$” with “`$”.

For example:

Does not work:
$url=”http://crmserver.company.com/Organization/xrmservices/2011/OrganizationData.svc/ContactSet$filter=StateCode/Value eq 0″

Works:
$url=”http://crmserver.company.com/Organization/xrmservices/2011/OrganizationData.svc/ContactSet`$filter=StateCode/Value eq 0″

Gets me every time, and I can’t figure out why my filters are being ignored!

,

2 Responses to When using PowerShell to pull REST data from MS CRM, escape `$filter !

  1. Steve September 29, 2016 at 9:24 am #

    Or try single quotes instead of double quotes being there are no single quotes or other variables that need to be expanded in the string.

  2. jbmurphy September 29, 2016 at 9:32 am #

    I always forget that too! I hardly ever use single quotes because I usually am mashing things together!
    Thanks for taking the time to comment.

Leave a Reply