title: A positional parameter cannot be found that accepts argument '\*'
body: <p>I have a number of web services that I'm attempting to use PowerShell to install on a DEV server. I want to include, in the script, a section that copies all files and folders from a staging area to the respective folder on the DEV server. </p>
  
  <p>In order to do this I've created two parallel string arrays - one containing the direct file paths of the staging folders and the other with the names of each folder on the DEV server (I use a couple other variables to store the rest of the directory). </p>
  
  <p>I'd like to create a <code>for</code> loop and simply iterate over both arrays to complete the transfer of files/folders from staging to dev server. However when the loop runs the <code>copy-item</code> command gives this error each time</p>
  
  <blockquote>
    <p>Copy-Item : A positional parameter cannot be found that accepts argument '*'.</p>
  </blockquote>
  
  <p>If I decide not to use the loop, the error goes away and the files transfer properly. Only a couple days new to PowerShell so I'm not sure what's going on/haven't been able to find anything specific to this on the web. </p>
  
  <p><strong>Variables</strong></p>
  
  <pre><code>#web services
  $periscopeWebServices = "periscopeWebServices"
  $periscopeRetrieveComments = "periscopeRetrieveComments"
  $periscopeRetrieveGeneral = "periscopeRetrieveGeneral"
  $periscopeRetrieveMasterSubs = "periscopeRetrieveMasterSubs"
  $periscopeRetrieveProducers = "periscopeRetrieveProducers"
  $periscopeRetrieveProfiles = "periscopeRetrieveProfiles"
  $periscopeRetrieveRelationships = "periscopeRetrieveRelationships"
  $periscopeSearch = "periscopeSearch"
  $periscopeServicesArray = @($periscopeRetrieveComments, $periscopeRetrieveGeneral, 
                              $periscopeRetrieveMasterSubs, $periscopeRetrieveProducers, 
                              $periscopeRetrieveProfiles, $periscopeRetrieveRelationships, 
                              $periscopeSearch)
  
  
  #staging areas
  $stagingComments = "\\install\PeriscopeServices\periscopeWebServices\periscopeRetrieveComments"
  $stagingGeneral = "\\install\PeriscopeServices\periscopeWebServices\periscopeRetrieveGeneral"
  $stagingMasterSubs = "\\install\PeriscopeServices\periscopeWebServices\periscopeRetrieveMasterSubs"
  $stagingProducers = "\\install\PeriscopeServices\periscopeWebServices\periscopeRetrieveProducers"
  $stagingProfiles = "\\install\PeriscopeServices\periscopeWebServices\periscopeRetrieveProfiles"
  $stagingRelationships = "\\install\PeriscopeServices\periscopeWebServices\periscopeRetrieveRelationships"
  $stagingSearch = "\\install\PeriscopeServices\periscopeWebServices\periscopeSearch"
  $stagingArray = @($stagingComments, $stagingGeneral, $stagingMasterSubs, $stagingProducers
                    $stagingProfiles, $stagingRelationships, $stagingSearch)
  
  #server variables
  $domain = "InsideServices.dev.com"
  $directory = "E:\webcontent"
  $domainpath = "$directory\$domain"      
  </code></pre>
  
  <p><strong>Loop - throws error on 'copy-item'</strong></p>
  
  <pre><code>#copy files
  Write-Host "Copying Files" -ForegroundColor Yellow
  For ($i=0; $i -lt $periscopeServicesArray.Length; $i++)
  {
      Write-Host "Copying $($periscopeServicesArray[$i])" -ForegroundColor Yellow
      if(Test-Path -path "$domainpath\$periscopeWebServices\$($periscopeServicesArray[$i])")
      {
          copy-item -Path $($stagingArray[$i])\* -Destination $domainpath\$periscopeWebServices\$($periscopeServicesArray[$i]) -recurse -Force
      }
  }
  </code></pre>
  
  <p><strong>Succesful copy-item command</strong></p>
  
  <pre><code>copy-item -Path $stagingComments\* -Destination $domainpath\$periscopeWebServices\$periscopeRetrieveComments -recurse -Force
  </code></pre>