title: Remove [ character from a text file with PowerShell
body: <p>How can I remove the <code>[</code> character from a text file?</p>
  
  <p>My text file contains lines like this:</p>
  
  <pre><code>[Adminlogin] 172.16.48.131 Wednesday Jan102018 07:05:36
  </code></pre>
  
  <p>And I would like to remove the <code>[</code>.</p>
  
  <p>When I run this,</p>
  
  <pre><code>$file = "MyFile.txt"
  Get-Content $file  | Foreach {$_ -replace "[", ""}  | Set-Content "Myfile-1.txt"
  </code></pre>
  
  <p>I get an error</p>
  
  <blockquote>
    <p>The regular expression pattern [ is not valid</p>
  </blockquote>
  
  <p>However when I run this to remove the <code>]</code>,</p>
  
  <pre><code>$file = "MyFile.txt"
  Get-Content $file  | Foreach {$_ -replace "]", ""}  | Set-Content "Myfile-1.txt"
  </code></pre>
  
  <p>It runs with no problem.</p>