【问题标题】:Powershell - Run a script located at a remote machine which inturn access files from a network sharePowershell - 运行位于远程机器上的脚本,该脚本反过来从网络共享访问文件
【发布时间】:2011-01-04 16:43:38
【问题描述】:

我正在尝试使用以下命令执行位于远程计算机上的 powershell 脚本,它运行良好

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

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

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

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

谢谢! 桑吉夫

【问题讨论】:

    标签: powershell powershell-2.0 powershell-remoting


    【解决方案1】:

    您需要的是 credSSP。检查这篇文章: http://www.ravichaganti.com/blog/?p=1230

    【讨论】:

    • 感谢您的链接。但我试图在 Windows Server 2003 中使用远程处理,但无法使用 CredSSP。有解决办法吗?
    • 不幸的是,没有解决方法。您可以做的一件事是使用域控制器作为第二个跃点。这意味着您在 2003 系统上启动 Invoke-Command 并在域控制器上运行脚本块,然后访问第三台机器的文件共享。域控制器 (windows 2008/2008 R2) 始终委托凭据,您不需要使用 CredSSP
    • 我终于找到了一种方法,方法是在 profile.ps1 脚本中添加一个新的 psdrive 到网络共享并使用该驱动器。 tinyurl.com/6ef4sb2
    【解决方案2】:

    使用invoke-command 远程调用power shell 脚本时,将凭据作为参数传递给它。将这些凭据从install.ps1 传递给next 脚本。

    【讨论】:

      猜你喜欢
      • 2017-11-30
      • 1970-01-01
      • 2021-06-15
      • 1970-01-01
      • 1970-01-01
      • 2011-12-09
      • 2013-02-18
      • 1970-01-01
      • 2017-03-14
      相关资源
      最近更新 更多