我有以下组件:
最后,让计划任务作为服务帐户运行,该服务帐户调用powershell作为服务帐户,运行该进程并执行ssh命令。
如果有帮助:
#Starts the vcenter2 server. #if the server is already started, it will tell you so. #Stop an error from occurring when a transcript is already stopped $ErrorActionPreference="SilentlyContinue" Stop-Transcript | out-null #Reset the error level before starting the transcript $ErrorActionPreference="Continue" Start-Transcript -path C:\Scripts\logs\StartTheVCenter2Server.log -append #Run plink and reference the commands file to start up the server Start-Process "C:\Program Files (x86)\PuTTY\plink.exe" -Argumentlist "-agent -m C:\Scripts\idrac_powerup_commands.txt root@[servernameredacted]" -wait -RedirectStandardOutput "C:\Scripts\logs\plinklog.log" #Clean-up Stop-Transcript
思考? 我可能会使用Invoke-Command来查看是否可以将输出redirect到我的日志中。
谢谢!
plink.exe “悬挂”,我见过的一般原因是提示将主机密钥添加到registry。 不过,我认为主机密钥已经在你的registry中了。 我会添加-batch参数给plink ,看看你是否得到了一个与一个挂起的失败。 至less应该让你走上正确的道路。
您的Plink调用正在使用-agent (pageant)进行身份validation,但您尚未明确启动该服务,因此可能会导致您的私钥导出到密码较less的密钥文件,并直接使用-i (身份)的论点,看看是否是authentication过错。 还要临时添加-v (详细)选项,并检查事件日志。
对于它的价值,我有一个非常类似的问题 – psftp不会在Windows 7中计划的脚本中运行,无论用户是否login。 在我的情况下,我正在使用在命令行中引用的选美保存的会话; 并且由于该选美没有在与计划任务相同的上下文中运行,所以它将挂起。 我通过在psftp中使用-i标志并在脚本中引用私钥的位置来解决问题。