Skip to content

Copying file to remote computer fails #341

@arudell

Description

@arudell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions