我希望Windows 2003服务器触发脚本以在另一台Windows Server 2008计算机中触发另一个脚本。
我被告知Powershell可以做到这一点,这很好,但我需要更具体的细节。
有没有人对此有任何提示?
谢谢!
答案 0 :(得分:14)
答案 1 :(得分:6)
查看AT命令的语法。您可以使用它来安排在远程计算机上运行的进程。
AT命令安排命令和程序在计算机上运行 指定的时间和日期。必须运行Schedule服务才能使用 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.
答案 2 :(得分:3)
最简单的使用方式将分两步进行
一个。将cygwin安装到远程PC
湾运行ssh hudson @ mcs'/cygdrive/c/path_to_script.bat'
答案 3 :(得分:1)
关于PsExec
,我强烈建议使用Cygwin / OpenSSH。
SSH具有多种优势(超过PsExec
等工具甚至是定制服务)
例如,尝试与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 /退出状态转移到本地 shell进行检查
(将远程执行集成到本地脚本逻辑中的杀手级功能和常见要求)
Cygwin / OpenSSH提供标准 POSIX shell环境
(有效的时间投入,基本工具,跨平台准备,兼容的习惯等)
您仍然可以/始终运行所有原生 Windows应用程序
(包括*.bat
处理器自动执行cmd
个文件)
您可以使用公钥配置无密码身份验证 (考虑无人值守的自动化任务)
提示强>
最初有一个问题我有问题:
后台sshd
服务必须在用户的图形会话中执行应用程序
(使应用程序窗口出现在桌面环境中)。
我的acceptable solution在用户的GUI会话中直接运行sshd
service
(当用户登录时自动启动,按照链接查看配置文件更改):
/usr/sbin/sshd -f /home/user/sshd_config
答案 4 :(得分:0)
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Q_22959948.html接受的解决方案是:
我提供的是一个需要的脚本 参数...在这种情况下需要4。 1)服务器:如果你通过-server它会 只做一个服务器2)列表:你 可以提供服务器的列表文件。 3)服务:您的服务名称 想要修改4)详细:不是 在这里使用。
我确实有些错误 在以下代码中更改。使用 将代码剪切/粘贴到名为的文件中 SET-RemoteService.ps1。确保 设置您的executionpolicy运行 脚本......默认情况下不会。您 通过使用。来做到这一点 set-executionpolicy cmdlet。 PS> Set-Executionpolicy“RemoteSigned”为 运行你做的PS脚本> C:\ PathToScript \设置RemoteService.ps1 -list c:\ ServerList.txt -service“DHCP”
######################### Param($ server,$ list,$ service,[switch] $ verbose)if($ Verbose){$ VerbosePreference = “继续”} if($ list){ foreach($ srv in(get-content $ list)) { $ query =“从Win32_Service中选择*,其中Name ='$ service'” $ myService = get-WmiObject -query $ query -computer $ srv $ myService.ChangeStartMode( “自动”) $ myService.Start() if($ server){ $ query =“从Win32_Service中选择*,其中Name ='$ service'” $ myService = get-WmiObject -query $ query -computer $ server $ myService.ChangeStartMode( “自动”) $ myService.Start()}