Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying file to remote computer fails #341

Open
arudell opened this issue Oct 25, 2024 · 0 comments
Open

Copying file to remote computer fails #341

arudell opened this issue Oct 25, 2024 · 0 comments

Comments

@arudell
Copy link
Member

arudell commented Oct 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant