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!


Posted

in

,

by

Comments

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

  1. Steve Avatar
    Steve

    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 Avatar

    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

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