microsoft / microsoft/SdnDiagnostics

Copying file to remote computer fails

Open
#341 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
34
Forks
6
Avg merge
5d 14h
Merged PRs (30d)
5

Description

With the introduction of #212 we are now encountering a new issue when attempting to copy file(s) to the destination. Copy-Item has some odd behavior and unfortunately, we went from one error to another with #212.

In the event that the $Path for Copy-Item is a leaf item, it expects the $Destination to exist, otherwise will fail with an error indicating it cannot find the item. Only when $Path is a directory, does Copy-Item build the directory structure for $Destination.

Need to implement something along the lines such as:

$isFile = Test-Path -Path $_ -PathType Leaf
if ($isFile) {
   if (Test-Path -Path (Split-Path -Path $Destination -Parent) -Type Container) {
        $null = New-Item -Path $Destination -ItemType Directory -Force
   }
}

We would have to do some calculation above to determine if $Destination is Leaf or Container as well to figure out how far we must build the directory structure.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the remote file-copy logic changed for #212 and read how it invokes Copy-Item, Test-Path, Split-Path, and New-Item. Reproduce a copy where $Path is a leaf and the destination structure is absent; done means the required destination directories are created without the current failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.