windows - Ansible运行远程exe文件

标签 windows ansible winrm

如何使用 Ansible 在远程 Windows 计算机上执行 exe 文件?我使用了原始、脚本和命令模块,但问题是,exe 文件在不同的 session 中运行,并且无法在远程计算机的桌面中看到应用程序 UI。

第二个问题是 ansible playbook 在 exe 执行后不会继续前进。

我们可以在事件桌面 session 中运行 exe 吗?

最佳答案

我可以使用 psexec 解决这些问题。

#Creating the credential for the invoke-command.
$strScriptUser = "COMPUTERNAME\USer"
$strPass = "PASSWORD"
$PSS = ConvertTo-SecureString $strPass -AsPlainText -Force
$cred = new-object system.management.automation.PSCredential $strScriptUser,$PSS

#Invoke-Command to call the psexec to start the application.

invoke-command -Computer "." -Scriptblock {
c:\AnsibleTest\ps\psexec.exe -accepteula  -d -h -i 1 -u COMPUTERNAME\USER -p PASSWORD PATH_TO_THE_EXE\PROGRAM.EXE
}  -Credential $cred

关于windows - Ansible运行远程exe文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28230063/

相关文章:

windows - 使用 Selenium 的弹出窗口问题

powershell - 使用 C# API 连接到 Powershell Remoting

windows - 查找域名的IP

C# 文本框按键控件帮助

ansible - 从命令行覆盖 Ansible playbook 的主机变量

docker-compose - 在ansible中创建一个带有循环的docker-compose

powershell - 如何获得特定winrm属性的值?

windows - WSMan 和基本授权

python - 由于 hdf5 错误,无法安装库

python - 为什么可以在ansible中使用分割过滤器?