title: How to use a method with a pipe operator
body: <p>This command returns the expected result</p>
  <pre><code>'d   d' -replace '\s+', ' ' | echo
  </code></pre>
  <blockquote>
  <p>'d d'</p>
  </blockquote>
  <p>Now I want ot use this method replace on the content of a file.</p>
  <pre><code>new-Item a.txt
  echo 'd   d' &gt;a.txt
  
  cat a.txt| -replace '\s+', ' ' | echo
  </code></pre>
  <blockquote>
  <p>-replace : The term '-replace' is not recognized as the name of a cmdlet, function, script file, or operable program.</p>
  </blockquote>
  <p><a href="https://tio.run/##K8gvTy0qzkjNyfn/Py@1XNezJDVXIVGvpKKEKzU5I19BPUVBQSFFXcEOIpacWAKV5YLJ6BalFuQkJqcqqMcUa6vrKKgDYY0CSDNCdQ0eVf//AwA" rel="nofollow noreferrer">code</a></p>