title: How to escape square brackets in file paths with Invoke-WebRequest's -OutFile parameter
body: <p>When you include something like <code>[1]</code> in a file name like <code>File[1].txt</code> used with the <code>Invoke-WebRequest</code> and the <code>-OutFile</code> parameter you get an error <code>Cannot perform operation because the wildcard path File[1].txt did not resolve to a file.</code></p>
  
  <p>This is caused by the behavior documented <a href="https://github.com/PowerShell/PowerShell/issues/3174" rel="noreferrer">here</a>.</p>
  
  <p>With other cmdlets you would use <code>-LiteralPath</code> to force the path to be taken literally but in this case that is not an option.</p>
  
  <p>I have tried escaping the <code>[</code> and <code>]</code> characters with ` or <code>\</code> but it still gives the same error.</p>
  
  <p>To simplify testing you can reproduce the same issue with <code>Out-File</code>, <code>Test-Path</code>, etc.</p>
  
  <pre><code>#Fails
  Out-File -FilePath "file[1].txt"
  Out-File -FilePath "file`[1`].txt"
  Out-File -FilePath "file\[1\].txt"
  
  #Succeeds
  Out-File -LiteralPath "file[1].txt"
  
  #Fails
  Test-Path -Path "file[1].txt"
  
  #Succeeds
  Test-Path -LiteralPath "file[1].txt"
  </code></pre>
  
  <p>How can I escape characters that would be used to express wildcards in <code>-Path</code>, <code>-FilePath</code>, <code>-OutFile</code>, etc. so that they function like the string was specified with <code>-LiteralPath</code> since <code>-LiteralPath</code> isn't available with <code>Invoke-WebRequest</code>?</p>