title: Using Move-Item -Destination to move files to a new share
body: <p>I have written a script that prompts the user to answer a series of questions.  Once those questions are answered, the script determines (based on the answer provided) what files need to be moved from the source path to the destination path.</p>
  
  <p>Everything worked fine with the script until I modified it to include user input for the destination path (before this I put the path in the script) as you will see in the <code>$endpath</code> variable.</p>
  
  <p>When I run the script, it looks as if it is running fine, completes, but it didn't move the files.</p>
  
  <pre><code>$earliesttime = "00/00/0000"
  $lasttime = "00/00/0000"
  $size2 = 0
  $user = ""
  $sourcepath = $null
  $endpath = $null
  while ($sourcepath -eq $null) {
      $sourcepath = Read-Host "Enter source file path"
  }
  Set-Location $sourcepath
  while ($endpath -eq $null) {
      $endpath = Read-Host "Enter destination file path"
  }
  Set-Location $endpath
  Write-Host
  switch ($what = Read-Host "Do you want to search by owner?") {
      No {
          while ($earliesttime -eq "00/00/0000") {
              Write-Host
              $earliesttime = Read-Host "What is the earliest date of modification?"
          }
          while ($lasttime -eq "00/00/0000") {
              Write-Host
              $lasttime = Read-Host "What is the latest date of modification?"
          }
          Write-Host
          $skip1 = Read-Host "Do you want to search by size?"
          if ($skip1 -match "yes") {
              while ($size2 -eq 0) {
                  $size2 = Read-Host "What is the size in KB of the objects you are looking for?"
              }
              if ($size2 -ge 1) {
                  Get-ChildItem -Recurse | Where-Object {
                      $_.Length /1KB -ge $size2 -and
                      $_.LastWriteTime -ge $earliesttime -and
                      $_.LastWriteTime -le $lasttime
                  } | Move-Item -Destination "$endpath"
              }
          } elseif ($skip1-match "no") {
              Get-ChildItem -Recurse | Where-Object {
                  $_.LastWriteTime -ge $earliesttime -and
                  $_.LastWriteTime -le $lasttime
              } | Move-Item -Destination "$endpath"
          }
      }
      Yes {
          while ($user -eq "") {
              Write-Host
              $user = Read-Host "What is the name of the owner (i.e. john.smith)?"
          }
          while ($earliesttime -eq "00/00/0000") {
              Write-Host
              $earliesttime = Read-Host "What is the earliest date of modification?"
          }
          while ($lasttime -eq "00/00/0000") {
              Write-Host
              $lasttime = Read-Host "What is the latest date of modification?"
          }
          Write-Host
          $skip1 = Read-Host "Do you want to search by size?"
          if ($skip1 -match "yes") {
              while ($size2 -eq 0) {
                  $size2 = Read-Host " What is the size in KB of the objects you are looking for?"
              }
              if ($size2 -ge 1) {
                  Get-ChildItem -Recurse | Where-Object {
                      $_.GetAccessControl().Owner -eq $user -and
                      $_.Length /1KB -ge $size2 -and
                      $_.LastWriteTime -ge $earliesttime -and
                      $_.LastWriteTime -le $lasttime
                  } | Move-Item -Destination "$endpath"
              }
          } elseif ($skip1 -match "no") {
              Get-ChildItem -Recurse | Where-Object {
                  $_.GetAccessControl().Owner -eq $user -and
                  $_.LastWriteTime -ge $earliesttime -and
                  $_.LastWriteTime -le $lasttime
              } | Move-Item -Destination "$endpath"
          }
      }
  }
  </code></pre>