title: The property 'Name' cannot be found on this object. Verify that the property exists
body: <p>My script is working, but I'm getting this error:</p>
  
  <blockquote>
    <p>The property 'Name' cannot be found on this object. Verify that the property exists.</p>
  </blockquote>
  
  <p>I'm looping to copy folders. Any idea what is going on?</p>
  
  <pre class="lang-cs prettyprint-override"><code>    $source50 = "c:\folder\"
      $destination50 = "c:\folder1\"
  
      for ($i = 1; $i -le 7; $i++) {
          $d = ((Get-Date).AddDays( + $i))
          $d2 = $d.ToString("yyyy-MM-dd")
          $v = Get-ChildItem $source50 -Recurse -Include "$d2"
   foreach ($file in $v) 
        {
  
                 if ( Test-Path  $v.FullName)
  
  
                   {  
                      if (-not (Test-Path -Path $destination50$d4)){
                      New-Item -ItemType directory -Path $destination50$d4 
  
                      }
  
  
                       Write-Output "Copy ok " $v.FullName     
                       $bd= Copy-Item $v.FullName -Destination $destination50$d4 
                       break 
  
  
                    }
  
         }
  </code></pre>
  
  <p>The code is giving the error:</p>
  
  <pre>
  ok C:\folder\2017-12-27
  ok C:\folder\2017-12-28
  The property 'Name' cannot be found on this object. Verify that the property
  exists.
  At line:16 char:11
  +       if ($v.Name -eq $d2) {
  +           ~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], PropertyNotFoundException
      + FullyQualifiedErrorId : PropertyNotFoundStrict
  
  ok C:\folder\2017-12-30
  The property 'Name' cannot be found on this object. Verify that the property
  exists.
  </pre>