title: Illegal characters in Powershell filepath error
body: <p>I'm trying to get a script to find and delete specific files on remote hosts. To do this the script cycles through a list of locations and file names in a couple of arrays.</p>
  
  <p>One of the files I need to do this with is on called <code>101" "" "lyrics.vbs</code> but I can't find a way for it to detect the file without giving the error message <code>test-path : Illegal characters in path</code> and reference to the <code>""</code> marks.  I've searched around this and tried the solution of saving the file path into a text file and then calling it with <code>get-item -literalpath</code> but this didn't work either.  I've also tried using the backtick <code>`</code> before each of the <code>"</code> in the file paths but still get the same results.  The part of the code that is used for this is:</p>
  
  <pre><code> $users | ForEach-Object {
  #Creating an array file locations
  $filelist = @("c$\Users\$($_.Name)\101__lyrics.vbs","c$\Users\$($_.Name)\101" "" "lyrics.vbs","c$\Users\$($_.Name)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\101" "" "lyrics.vbs&gt;")
  
     foreach ($file in $filelist)
      {
       $newfilepath = Join-Path "\\$computer\" "$file"
               if (test-path $newfilepath)
               {
               Write-Host -foregroundcolor Yellow "$newfilepath file exists"
                      try
                     {
                         Remove-Item $newfilepath -force -recurse -ErrorAction Stop
                     }
                     catch
                     {
                         Write-host -ForegroundColor red "Error while deleting $newfilepath on $computer.`n$($Error[0].Exception.Message)"
  
                       continue
                      }
  
                    Write-Host  -ForegroundColor green "$newfilepath file deleted`n"
                }
  
      }
  </code></pre>
  
  <p>Thank you very much.</p>
  
  <p>Edit: The error message I get when adding backticks before each <code>"</code> and using <code>-literalpath</code> is:</p>
  
  <pre class="lang-none prettyprint-override"><code>test-path : Illegal characters in path.
  At .\Rb.ps1:126 char:22
  +                  if (test-path -literalpath $newfilepath)
  +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (\\AAZAJCMW0459\...`" `"lyrics.vbs:String) [Test-Path], ArgumentException
      + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand
  </code></pre>