0

I have this script:

$destination = "\\myserver\beta\c#apps\MyFolder\";

#$source = "`'$bamboo.build.working.directory`'";
$source = $env:bamboo_Publish_Location;

write-host "Running: Copy-Item -Recurse -Verbose -Path `"$source`" -Destination `"$destination`""
Copy-Item -Recurse -Verbose -Path "$source" -Destination "$destination"


#$cmd = "& Copy-Item -Verbose -Path "$source" -Destination "$destination""
#write-host "Running: $cmd"
#Invoke-Expression $cmd

#copy-item -Recurse -Path $source -destination $destination

#write-host "Running: copy-item $source $destination -Recurse"
#copy-item `"$source`" `"$destination`" -Recurse

That's throwing this error:

Copy-Item : The network name cannot be found. At C:\Program Files\Atlassian\Application Data\bamboo-home\temp\3047425-3244033-3932203-ScriptBuildTask-7378141679293696144.ps1:7 char:1 + Copy-Item -Recurse -Verbose -Path "$source" -Destination "$destinatio ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (\myserver...MyFolder:String) [Copy-Item], IOException + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.CopyItemCommand

And I have no idea why or how to make this work...

If it helps, the write-host spits out:

Running: Copy-Item -Recurse -Verbose -Path "C:/Program Files/Atlassian/Application Data/bamboo-home/xml-data/build-dir/CI-BD-JOB1/Publish/" -Destination "\myserver\beta\c#apps\MyFolder\"

How can I fix this?

4
  • 2
    Can you access the UNC path? Does gci \\myserver\beta work? Commented Apr 14, 2020 at 22:27
  • 2
    Also, can you verify $destination? in the code sample the UNC has two slashes, but the Write-Host output provided only has one e.g. "\myserve Commented Apr 14, 2020 at 22:31
  • @HAL9256 That appears to be a rendering artifact. In the question markdown Write-Host does output the path beginning with \\. Commented Apr 15, 2020 at 0:04
  • @vonPryz Agck... it was the wrong path. Commented Apr 15, 2020 at 16:51

1 Answer 1

0

I was using the wrong path. Thanks to vonPryz for pointing out to check via gci.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.