自动化远程机器任务

发布于 2024-10-22 03:37:40 字数 636 浏览 1 评论 0原文

这就是我想要做的:

  1. 连接到 VPN(我使用 rasdial)
  2. 检查 VPN 中活动虚拟机的列表,然后连接到其中之一。 (我读到 vmrun 可以做到这一点,但我安装了虚拟基础设施库。我从哪里获得 vmrun 实用程序?)或者
  3. 检查给定的虚拟机是否已打开,如果没有打开,然后连接到它(mstsc 是我现在使用的是前台进程,还有什么可以在后台执行并告诉用户它已使用提供的凭据登录吗?顺便说一下,mstsc 不能帮助我检查状态或打开虚拟机电源。因此,我需要解决它)
  4. 连接后,连接到 UNC 路径 (\dir1\dir2),从那里复制一个文件夹并通过 ftp 进行传输。我可以管理 FTP 部分,但我不确定如何处理 UNC 路径内容。我知道 Pushd 但 Pushd 似乎不接受用户/密码。我的 UNC 有用户名/密码。我也认为我可以在远程服务器的批处理文件中完成它。我计划使用 psexec 在远程服务器上执行此批处理。 一切完成后,断开 VPN(再次 rasdial)

我有关于如何完成各个任务的零碎信息,但是我可以使其成为一个完整的任务,因为我缺少有关如何集成所有任务的知识。批处理脚本是我擅长的,所以我选择了它。但如果您认为有更好的工具(AutoIT 可以做这种事情吗?)或其他一些编程语言,那么我很高兴知道。

感谢您抽出时间!

This is what I am trying to do:

  1. Connect to a VPN (I use rasdial)
  2. Check list of active virtual machines in VPN and then connect to one. (I have read that vmrun can do it BUT I have Virtual Infrastructure Library installed. Where do I get vmrun utility from?) OR
  3. Check if a given virtual machine is turn on, if not turn it on and then Connect to it (mstsc is what I am using as of now and it is foreground process. Is there anything else that could do it background and just tell the user that it is logged in with the provided credentials? By the waym mstsc does not help me in checking the state or powering on the virtual machine. So, I need a work around for it)
  4. Once its connected, connect to a UNC path (\dir1\dir2) copy a folder from there and ftp it. I can manage the FTP part however I am not sure how do I handle the UNC path stuff. I know pushd but pushd does not seem to take user/password. My UNC has a username/password. Also I think I can do it in a batch file in the remote server. I am planning to use psexec to execute this batch at remote server.
    Once everything is done, Diconnect the VPN (rasdial again)

I have bits and pieces of information on how to achieve individual tasks however I can make it a complete one because I am missing knowledge on how to integrate it all. Batch script is what I am good at so I chose it. But if you think there are any better tools (Can AutoIT do this kind of stuff?) or some other programming languages then I would be glad to know.

Thanks for your time!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栀子花开つ 2024-10-29 03:37:40

对于 #3:

根据 mstsc 的使用情况,我猜测这些是 Windows 机器。要让当前用户登录 Windows 计算机、WMIC 或 Sysinternals PSLoggedOn

这里有一篇包含语法和更多建议的帖子:

https://serverfault.com/questions/32633/how-to-check-who-is-currently-logged-on-to-windows-workstation-from-command-line

我非常喜欢使用命令行 telnet 客户端来查看系统是否处于活动状态:

telnet 445

如果响应包含消息“无法在端口 445 上打开与主机的连接:连接失败”的任何部分,则服务器不可用。当然,只有当您的环境中端口 445 没有被阻止时,这才有效。

我在自动化脚本中使用的另一个很棒的工具是 STAF。它需要单独安装和一些时间配置,但提供了很多快捷方式,解决了我遇到的多个脚本问题。

祝你好运。

For #3:

I am guessing these are Windows machines based on the mstsc usage. To get the current user logged into a Windows machine, WMIC or Sysinternals PSLoggedOn

There is a post with syntax and more suggestions here:

https://serverfault.com/questions/32633/how-to-check-who-is-currently-logged-on-to-windows-workstation-from-command-line

I am a big fan of using the command-line telnet client to see if a system is alive:

telnet 445

If the response contains any portion of the message "Could not open connection to host, on port 445: Connect failed", the server is unavailable. This of course only works if port 445 is not being blocked in your environments.

Another great tool that I use in my automation scripts is STAF. It requires a separate installation and some time configuring, but offers a lot of shortcuts that have solved more than one scripting problem I have come up against.

Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文