Invoke-RestMethod URL with backslash
<p>I've found a lot of information about dealing with forward slashes in <code>Invoke-RestMethod</code>, but I can't seem to find anything about handling backslashes.  I know they should be avoided, but I've got some constraints to work within where I can't change the information.  Here's what I'm trying to do:</p>

<pre><code>Invoke-RestMethod "http://blah.blah.net/api/Reporting/$ServerName" -Method Get
</code></pre>

<p>It works fine on other instances, but this time <code>$ServerName</code> will have a value like "Server1\SQLserv".  I've tried using <code>$ServerName -replace "\", "\\\"</code> and other variants of that, as well as substituting in <code>%5C</code> (URL escape character) for the backslash.  Nothing seems to be working.  Anyone encountered (and solved!) this?</p>

<p>EDIT: Here's the specific error I'm getting.  Note that it does work fine for other servers I'm querying against, despite saying the service has been removed:</p>

<pre>Invoke-RestMethod : The resource you are looking for has been removed, had its
name changed, or is temporarily unavailable.
At line:1 char:1
+ Invoke-RestMethod "http://blah.blah.net/api/Report ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand</pre>