如何使用 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/