Reputation: 301
I have a job in a rundeck that connects to windows machine by some domain network's user credentials and runs the script that copies some folder from another machine in the domain network. Connection to windows node done by WinRM.
When I run that script by rundeck job it fails with error
[ERROR ] Test-Path : Access is denied
10:43:56 At E:\scripts\site_backup.ps1:20 char:10
10:43:56 + if(-not (Test-Path $BackupDirectory)) {
10:43:56 + ~~~~~~~~~~~~~~~~~~~~~~~~~~
PermissionDenied: (\\some.path.local\dprr...rw-tests-pq:String) [Test-Path], UnauthorizedAccessException
However, if I run that script under the same user connecting by RDP to that machine it works fine.
I suspect WinRM service does not have enough privileges. Maybe I am wrong. How can I resolve that issue? Any help will be appreciated.
Upvotes: 1
Views: 1022
Reputation: 301
As @MegaDriver68k said, it was "double hop" Powershell issue. In order to overcome that on Rundeck it was required:
winrm-authtype: credssp
on node yaml file (I added node to rundeck via adding yaml file)
pip install pywinrm[credssp]
Upvotes: 1
Reputation: 4325
That's "double hop" PowerShell problem. You can check a full explanation here, and here a good approach. Also here a good wokaround.
Upvotes: 1