在多个远程服务器上运行主脚本文件而不更改配置

时间:2013-11-10 16:50:33

标签: powershell batch-file vbscript remote-access

我在Remote Server1上有一个master.bat文件,我希望在位于同一网络上的4个远程服务器上并行运行它,并且具有相同的用户名和密码以登录为Server1。 通过谷歌搜索,我已经探索了以下方法,但在我的情况下有一些限制:

1.PsExec tool : psexec \\Server1 C:\master.bat ---- But I am not allowed to install PsExec tool for security reasons.
2.Powershell : Invoke-Command -ComputerName $client -ScriptBlock { cd C:\master.bat} -Credential $(Get-Credential) -Authentication CredSSP ----But I have to enable PS Remoting (WinRM) on every remote machine on whom I need to execute scripts using PowerShell, for which I am not allowed.

还有其他方法可以在4台远程服务器上运行 master.bat master.ps1 吗?

如果我没有记错的话......

1.Installing PsExec tool has security drawbacks...??
2.Enabling PS Remoting (WinRM) also has chances of security threats...??

1 个答案:

答案 0 :(得分:1)

执行此操作的一种方法是在要运行.bat文件的服务器上创建计划任务,然后使用schtasks.exe按需运行任务。

您还可以将WINRM设置为仅提供受约束的PS会话,该会话只能用于运行该.bat文件,使用会话配置中存储的凭据来消除对凭据委派的需要。

http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/27/an-introduction-to-powershell-remoting-part-five-constrained-powershell-endpoints.aspx

相关问题