Copy-Item from local storage to UNC is throwing error "Access Deny"

Greetings,
I am working on ClickOnce deployment. In the very last step I need to copy \bin\Release\app.publish|**.* into UNC path.
The command I am using is Copy-Item -Path $source -Destination $target -Force -PassThru -Verbose.
$target is \UNC\something\somthing. I am getting “Access is denied”
"
Copy-Item : Access is denied
At C:\Octopus\Work\20170821235000-610\Script.ps1:29 char:1
"
According to command [System.Security.Principal.WindowsIdentity]::GetCurrent().Name the script and deployment for this matter runs by NT AUTHORITY\SYSTEM

My question is how to run “Create Publish URL” step by octoupsDeploy@domainname.com ID? or how to fix “Assess is denied”?

Inna

Hi Inna,

Thanks for getting in touch!

What appears to be happening here is that the account that is executing your powershell doesn’t have enough permissions to access the network path. By default Octopus Tentacles execute powershell with the local System account, which is what your error logs are reporting.

Can you please confirm that you are executing this powershell script on a Tentacle (and not your Octopus Server)? If this is the case then I would recommend changing the user account that your Tentacle is running as, which can be done by following these instructions. If you need to execute the script on the Octopus server itself I would recommend installing the Tentacle agent on your Octopus Server and using the previously linked instructions (as although it is possible to run Octopus Server under a different user account it introduces a lot of complexities that are best avoided if possible).

Please let me know if this doesn’t resolve your issue or if you have any other questions,

Regards,

Alex

Thank you
Inna

Hi Inna,

No problems, glad we could help!

Regards

Alex