远程处理时通过Powershell脚本访问UNC路径时出错 [英] Error when accessing UNC paths through powershell script when remoting

查看:306
本文介绍了远程处理时通过Powershell脚本访问UNC路径时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Power Shell脚本内执行程序.使用Runspaces从C#方法调用PS脚本.该程序尝试对远程服务器上的配置文件进行更新.当我运行整个程序时,出现以下错误:

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:拒绝访问\\ some路径.

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

PS脚本位于远程服务器上.如果我直接在服务器上运行PS脚本,则PS脚本及其中的程序可以正常运行,并且能够访问远程系统.

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.

以前有人遇到过吗?有人告诉我这失败了,因为我正在通过Visual Studio和C#运行它,并且不允许我通过通过C#类运行的Powershell脚本访问网络资源.有人告诉我,我在运行空间中启动PS脚本所使用的权限没有转换为我在脚本中调用的程序.

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?

谢谢

推荐答案

您似乎正在尝试修改辅助服务器上UNC路径上的文件.由于存在古老的双跳"问题,因此无法使用.您在计算机A上,正在B上执行远程脚本,该脚本试图修改C上的文件.从A到B的身份验证无法再用于从B到C的连接.这是NTLM(Windows集成身份验证)的设计限制.

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.)

但是,一切都不会丢失:在将Powershell从A远程连接到B时,必须使用CredSSP身份验证,然后才能毫无问题地连接到C.

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.

参考:

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

这篇关于远程处理时通过Powershell脚本访问UNC路径时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆