Recently I posted an article showing how to prevent Invoke-RestMethod from unescaping dots and slashes. Soon after that I got a great advice from Dave Wyatt, moderator for powershell.org forum. What he suggested was to create a proxy function around [Invoke-RestMethod](http://technet.microsoft.com/en-us/Library/hh849971.aspx) cmdlet which will disable UnEscapingDotsAndSlashes when the call is made. After some reading about proxy functions in PowerShell [^1] [^2] (I couldn’t believe how easy it is to create proxy function in PowerShell) I decided on creating a proxy function which will extend [Invoke-RestMethod](http://technet.microsoft.com/en-us/Library/hh849971.aspx) cmdlet with an extra parameter AllowEscapedDotsAndSlashes. Setting it to true will disable UnEscapingDotsAndSlashes for the time the call to the server is made and then switch back to original setting. This approach restricts intrusion to selected call only, minimising chances of breaking other existing code.
While working on RabbitMQTools module I came across a problem with un-escaping forward slashes in Urls by [Invoke-RestMethod](http://technet.microsoft.com/en-us/Library/hh849971.aspx) cmdlet. The default Virtual Host on RabbitMQ is called "/" and when invoking Api methods it must be encoded with %2f:
With PowerShell 3.0 comes a wonderful Invoke-RestMethod cmdlet which much simplifies using REST services. The cmdlet handles all communication as well as data serialisation/deserialisation. Below gist shows how easy it is to make a call to get some data from the REST service:
Depending on the result type (atom, JSON, XML), the cmdlet will appropriately deserialise data and return richly object (or collection of objects).
First module introduces PowerShell and explains some basics, such as getting help, how to use pipeline or remoting. It has enough information to start using PowerShell as a consumer. I must say that as a developer I found it very useful, especially part about remoting. The second module goes deeper into the power of PowerShell and is mostly about extending it with own functions or modules. If you are thinking about creating some custom cmdlets, you have to watch this module. As a matter of fact, the material covered in the jump starts was enough for me to go and start creating my own module RabbitMQTools for administering RabbitMQ servers. During next few months I plan to share my discoveries related to writing PowerShell modules, so keep watching my blog.
For anyone who wants to start using PowerShell I strongly recommend watching those modules.