我想让 Windows 2003 服务器触发一个脚本,以触发另一台 Windows Server 2008 计算机中的另一个脚本。

有人告诉我 Powershell 可以做到这一点,这很好,但我需要更具体的细节。

有人对此有什么建议吗?

谢谢!

有帮助吗?

解决方案

PSEXEC 从Sysinternals的

其他提示

看到语法的AT命令。可以用它来安排一个处理到一个远程计算机上运行。

在AT命令安排命令和程序在计算机上运行 在指定的时间和日期。计划服务必须运行使用 AT命令。

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       Allows the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next Thursday).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.

最简单的方式,是使用将是在两个步骤中

一个。安装了cygwin到远程PC

湾运行ssh哈德森@ MCS '/cygdrive/c/path_to_script.bat'

谈到 PsExec, , 我会 强烈地 建议使用 Cygwin/OpenSSH 代替。

SSH 具有多种优势(相对于诸如 PsExec 甚至定制服务)。
例如,尝试使用 with PsExec 并实施这些 bash / ssh 命令行执行以下操作:

ssh user@remotehost "find . -name something" 2> all.errors.txt
ssh user@remotehost "grep -r something ."
if [ "$?" == "0" ]
then
    echo "FOUND"
else
    echo "NOT FOUND"
fi

祝你好运!

  • SSH 将(!)远程 stdout / stderr / 退出状态传输到 当地的 检查用外壳
    (将远程执行集成到本地脚本逻辑中的杀手级功能和常见要求)

  • Cygwin/OpenSSH 提供 标准 POSIX shell 环境
    (高效的时间投入、基本工具、跨平台准备、兼容的习惯等)

  • 你仍然可以/永远运行 都是本土的 Windows应用程序
    (包括自动执行 *.bat 文件由 cmd 处理器)

  • 您可以使用公钥配置无密码身份验证
    (考虑无人值守的自动化任务)


提示

最初我遇到了一个问题:
背景 sshd 服务必须在用户的图形会话中执行应用程序
(使应用程序窗口出现在桌面环境中)。

可接受的解决方案 对我来说正在跑步 sshd 服务 直接地 在用户的 GUI 会话中
(用户登录时自动启动,点击链接查看配置文件更改):

/usr/sbin/sshd -f /home/user/sshd_config

http://www.experts-exchange.com接受的解决方案/OS/Microsoft_Operating_Systems/Q_22959948.html 是:

  

我提供是一个脚本,它   参数......在这种情况下,需要4。   1)服务器:如果你通过-server它会   只有这样做,一台服务器2)名单:您   可以提供服务器的列表文件。   3)服务:服务您的姓名   要修改4)详细:不   在这里使用。

     

我确实有一些错误,我   在下面的代码改变。要使用   剪切/代码粘贴到一个名为   SET-RemoteService.ps1。确保   设置你的executionpolicy运行   脚本......它不会被默认。您   做到这一点,通过使用   设置ExecutionPolicy cmdlet来。 PS>   SET-Executionpolicy “下RemoteSigned” 来   运行你做PS脚本>   C:\ PathToScript \设置RemoteService.ps1   -list C:\ ServerList.txt -service “DHCP”

     #########################参数($服务器,$列表,$服务,[开关] $详细)      

如果($详细){$ VerbosePreference =   “继续”}如果($名单){       的foreach($在SRV(获得内容$列表))       {           $查询= “从win32_service时选择*其中Name = '$服务'”           $为myService = GET-WmiObject可以 - 查询$查询 - 电脑$ SRV           $ myService.ChangeStartMode( “自动”)           $ myService.Start()       }}如果($服务器){       $查询= “从win32_service时选择*其中Name = '$服务'”       $为myService = GET-WmiObject可以 - 查询$查询 - 电脑$服务器       $ myService.ChangeStartMode( “自动”)       $ myService.Start()}

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top