简体   繁体   English

powershell 远程脚本执行错误

[英]powershell remote script execution errors

I notice an error " Connecting to remote server usa-chicago failed with the following error message: Access is denied. For more information, see the about_Remote_Troubleshooting Help topic我注意到一个错误“连接到远程服务器 usa-chicago 失败,并显示以下错误消息:访问被拒绝。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题

  • CategoryInfo: OpenError: (usa-chicago:String) [], PSRemotingTransportException CategoryInfo: OpenError: (usa-chicago:String) [], PSRemotingTransportException
    • FullyQualifiedErrorId: AccessDenied,PSSessionStateBroken fullyQualifiedErrorId: AccessDenied,PSSessionStateBroken

". Below is the snippet used. Any suggestions? “。下面是使用的片段。有什么建议吗?

All the machines are inside a workgroup.所有机器都在一个工作组内。

$computers = gc "C:\servers.txt"
$source = "\\usa-chicago\c$\temp\one.jar"
$destination = "c$\july1\folder1\"

foreach ($computer in $computers) {
        Invoke-Command -Computername $computer -ScriptBlock  { & Copy-Item $using:source -Destination \\$using:computer\$using:destination -Force } 
 
}

Does your user account have access both to the computer and also the share you try to copy something to?您的用户帐户是否既可以访问计算机,也可以访问您尝试将内容复制到的共享? It could be that you hit the dreaded 'second hop' problem with PowerShell Remoting: https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/ps-remoting-second-hop?view=powershell-7可能是您使用 PowerShell 远程处理遇到了可怕的“第二跳”问题: https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/ps-remoting-second-hop?view=powershell -7

If this is the problem, there are some workarounds for that.如果这是问题所在,则有一些解决方法。 What i like to do is: In the Invoke Command, create a Scheduled Task with the commands you'd like to execute and pass the credentials into it, execute it, and delete it after.我喜欢做的是:在调用命令中,使用您要执行的命令创建一个计划任务,并将凭据传递给它,执行它,然后删除它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM