Powershell - 运行位于远程机器上的脚本,该脚本从网络共享访问文件 [英] Powershell - Run a script located at a remote machine which inturn access files from a network share

查看:33
本文介绍了Powershell - 运行位于远程机器上的脚本,该脚本从网络共享访问文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下命令执行位于远程机器上的 powershell 脚本,并且效果很好

invoke-command (powershell c:\install\install.ps1) -computername box1 -credential (get-credential)

上述脚本依次从网络共享复制文件(使用 robocopy) - 它失败,抱怨该位置不存在.发现这是由于权限问题.当我在脚本中明确提到使用以下凭据进行共享时,它会起作用

net use \share1\files 密码/user:username

有没有办法传递用于运行脚本的相同凭据以供脚本用于访问远程机器中的其他资源?

谢谢!桑吉夫

解决方案

您需要的是 credSSP.检查这个帖子:http://www.ravichaganti.com/blog/?p=1230>

I'm trying to execute a powershell script located at a remote machine using the below command and it works great

invoke-command (powershell c:\install\install.ps1) -computername box1 -credential (get-credential)

The above script in-turn copies files from a network share (using robocopy) - It fails complaining the location doesn't exist. Found out it was due to permission issue. It works when I explicitly mentioned in the script to use the following credentials for the share

net use \share1\files password /user:username

Is there a way to pass in the same credentials used to run the script to be used by the script to access other resources in the remote machine?

Thanks! Sanjeev

解决方案

What you need is credSSP. Check this post: http://www.ravichaganti.com/blog/?p=1230

这篇关于Powershell - 运行位于远程机器上的脚本,该脚本从网络共享访问文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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