PSEXEC开始给我一些麻烦,我决定在PowerShell中重新编码。
在PSEXEC开始弄乱之前,这个批处理命令曾经为我工作过:
psexec -accepteula \\<ServerToBeUpdated> -u <User> -p <Password> cmd /c "\\<ServerWithInstallationFile>\SystemEnv\Bin\Setup.exe /silent /Update"
我试图用Powershell中的Invoke-Command来做这件事,但到目前为止还没有运气。
我尝试了很多组合,并且搜索了很多内容,而且整体而言,PowerShell似乎并不喜欢我尝试安装的UNC路径。
以下是我所得到的:
Invoke-Command -ComputerName <ServerToBeUpdated> -ScriptBlock { Start-Process -FilePath "\\<ServerWithInstallationFile>\SystemEnv\Bin\Setup.exe" -ArgumentList "/update /silent" -wait }
我收到此错误消息:
由于错误,无法运行此命令:访问被拒绝 + CategoryInfo:InvalidOperation :( :) [Start-Process],InvalidOperationException
+ FullyQualifiedErrorId:InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
+ PSComputerName:DE5441
有些人说setup.exe已在本地复制到远程服务器上。但这对我来说似乎不是一个选择,主要有两个原因。
作为最后一点,我确实授予了使用Enable-PSRemoting命令远程运行PowerShell的访问权限,并且我也从这个简单的测试中获得了预期的结果:
Invoke-Command -ComputerName <ServerToBeUpdated> -ScriptBlock { Hostname }
答案 0 :(得分:3)
您遇到了所谓的双跳身份验证问题。如果使用普通身份验证,您将无法从正在调用命令的计算机上对第二台计算机进行身份验证。
要解决此问题,您可以使用CredSSP。
在正在调用的计算机上启用CredSSP:
Enable-WSManCredSSP -Role Server -force
在客户端启用CredSSP:
Enable-WSManCredSSP -Role Client -DelegateComputer server.domain.com -force
-delegateComputer
参数需要FQDN,但也需要使用通配符。
启用CredSSP后,您可以使用它来使用参数-authentication CredSSP