title: How do I do a string replacement in a PowerShell function?
body: <p>How do I convert function input parameters to the right type?</p>
  
  <p>I want to return a string that has part of the URL passed into it removed.</p>
  
  <p><strong>This works, but it uses a hard-coded string:</strong></p>
  
  <pre><code>function CleanUrl($input)
  {
      $x = "http://google.com".Replace("http://", "")
      return $x
  }
  
  $SiteName = CleanUrl($HostHeader)
  echo $SiteName
  </code></pre>
  
  <p><strong>This fails:</strong></p>
  
  <pre><code>function CleanUrl($input)
  {
      $x = $input.Replace("http://", "")
      return $x
  }
  
  Method invocation failed because [System.Array+SZArrayEnumerator] doesn't contain a method named 'Replace'.
  At M:\PowerShell\test.ps1:13 char:21
  +     $x = $input.Replace( &lt;&lt;&lt;&lt; "http://", "")
  </code></pre>