Access is denied error when copy file using Powershell

390 views
Skip to first unread message

Simone Bianchelli

unread,
Sep 24, 2024, 11:01:57 AM9/24/24
to rundeck-discuss
Hello, i have written a Powershell script that produces a .csv report in the folder C:\Temp of the remote Windows node then i have to copy it in a shared network folder (eg. \\sharednetwork\testfolder)
When i try to copy it i get access denied error:

[ERROR  ]  Execution finished with the following error (winrm-exec.py:378)[root]
[ERROR  ]  Copy-Item : Access is denied
At C:\WINDOWS\TEMP\79-357-N2ASVIL-AS-dispatch-script.tmp.ps1:26 char:1
+ Copy-Item -Path $csvFilePath -Destination $networkPath -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand
 
 (winrm-exec.py:379)[root]
Failed: NonZeroResultCode: [WinRMPython] Result code: 1

It's strange because the user which i run the script in Rundeck is administrator in the remote node and has rights to write files in the shared network folder.

If i open a Powershell shell directly in the remote Windows node and give the exact same command it works fine.
I also tested to open the path \\sharednetwork\testfolder directly in the Windows file manager from the remote Windows node and have no issues.

Any ideas?

Thanks in advice.

rac...@rundeck.com

unread,
Sep 24, 2024, 11:07:54 AM9/24/24
to rundeck-discuss
Hi, please check this. Probably you're facing the same issue.

Simone Bianchelli

unread,
Sep 24, 2024, 11:56:58 AM9/24/24
to rundeck-discuss
I didn't solved with the solution posted in the other thread, but i solved with the solution posted here by enabling and using CredSSP as authentication:

So it seems was the double hop issue.

Reply all
Reply to author
Forward
0 new messages