Error when accessing UNC paths through powershell script when remoting

被刻印的时光 ゝ 提交于 2019-12-11 07:47:00

问题


I am trying to execute a program inside of a power shell script. The PS script is being called from a C# method using Runspaces. The program tries to make an update to a config file on a remote server. When I run this whole thing I get the following error:

System.UnauthorizedAccessException: Access to the path \\some path is denied.

The PS script is on a remote server. If I run the PS script directly on the server then the PS script and the program inside of it runs fine and is able to access the remote system.

Has anyone run into this before? I was told that this is failing because I am running it through Visual Studio and C# and that I won't be allowed to access network resources through a powershell script that is being run through a C# class. Someone else told me that the permissions that I am using to start the PS script in the runspace are not translating to the program that I am calling within the script.

Other ideas and possible solutions?

Thanks


回答1:


It looks like you're trying to modify a file on a UNC path on a secondary server. This won't work due to the age old "double hop" problem. You are on machine A, executing a remote script on B that tries to modify a file on C. Your authentication from A to B cannot be reused to connect from B to C. This is a design limitation for NTLM (windows integrated authentication.)

However, all is not lost: You must use CredSSP authentication when connecting with powershell remoting from A to B, and then you can connect to C without a problem.

References:

  • http://tfl09.blogspot.ca/2013/02/powershell-remoting-double-hop-problem.html
  • http://www.ravichaganti.com/blog/?p=1230


来源:https://stackoverflow.com/questions/18002717/error-when-accessing-unc-paths-through-powershell-script-when-remoting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!