我正在寻找使用一个Windows命令来运行远程Python脚本的最快方法。到目前为止,我已经了解了Powershell,但是我似乎需要使用Invoke-Command
远程启动一个远程Powershell脚本,然后该脚本将在本地启动Python脚本。有没有更简单、更直接的方法来做到这一点?
发布于 2018-07-10 08:49:29
使用Invoke-Command
来实现这一点,它就是为此而设计的。
Invoke-Command -ComputerName $computerName {
# Assumes python.exe is on the remote $env:PATH
# and that you are running a python file, not module
python \path\to\file.py
}
作为一个额外的好处,如果你想同时在几台计算机上运行,-ComputerName
也允许你传入一组计算机名,如下所示:
Invoke-Command -ComputerName computer1, computer2, computer3, computerX {
# Assumes python.exe is on the remote $env:PATH
# and that you are running a python file, not module
python \path\to\file.py
}
https://stackoverflow.com/questions/51253045
复制相似问题