title: powershell Copy-Item Illegal characters in path
body: <p>I am getting the following error from TeamCity when trying to execute a PowerShell script.</p>
  
  <pre><code>Illegal characters in path.
       + CategoryInfo          : NotSpecified: (:) [Copy-Item], ArgumentException
       + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Co 
      mmands.CopyItemCommand
  </code></pre>
  
  <p>Below is my script block I'm calling...</p>
  
  <pre><code>$xcopyFolderBlock = 
  { 
   $destFolder    = ($args[0] | out-string)
   $sourceFolder  = $args[1]
  
   # See what value was passed in to the script block
   write-host "destFolder inside xcopyFolder code block: " $destFolder
   write-host "sourceFolder inside xcopyFolder code block: " $sourceFolder
  
   Copy-Item $sourceFolder $destFolder -force -recurse -verbose 
  } 
  </code></pre>
  
  <p>This is how I'm calling it...</p>
  
  <pre><code>Invoke-Command -ComputerName $web1Name -ScriptBlock $xcopyFolderBlock -ArgumentList(, $web1FolderServices, $nasFolderServices)
  </code></pre>
  
  <p>MY TeamCity log shows these values from the write-host calls in the script block...</p>
  
  <pre><code>destFolder inside xcopyFolder code block:  \\\s1-bridge-web1\BridgeWebServices\Prod\MileageCalculator\v1.1.31\Services
  
  sourceFolder inside xcopyFolder code block:  \\\s1-nas-1\software_dev\build\Prod\build_user\MileageCalculator\Services\\*
  </code></pre>