重新启动服务器列表 [英] Reboot a list of servers

查看:103
本文介绍了重新启动服务器列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我几乎是编码和创作的新手我需要你的帮助。我想重新启动一个远程服务器列表& ping他们直到他们上线。我尝试重新启动单个服务器,但是无法为多个服务器执行此操作。



Hello All,

I am pretty much a novice at coding & i need your help. I want to reboot a list of remote servers & ping them until they come online. I did try my hand at rebooting a single server, but was not able to do so for multiple servers.

ConnectionOptions co = new ConnectionOptions();
            System.Management.ManagementScope ms = new ManagementScope(sServer + "\\root\\CIMV2");
            System.Management.ObjectQuery oq = new ObjectQuery("select * from win32_Processor");
            ManagementObjectSearcher query1 = new ManagementObjectSearcher(ms, oq);
            ManagementObjectCollection moc = query1.Get();
            foreach (ManagementObject mo in moc)
            {
                string[] s = { "" };
                mo.InvokeMethod("Reboot", s);
                Console.WriteLine(mo.ToString());
            }





任意帮助多台服务器重启一次& ping他们直到他们在线将会有很大帮助!



谢谢!

// Vk



Any help in getting multiple servers to reboot at once & ping them until they are online will be of great help!

Thanks!
//Vk

推荐答案

我个人会使用PowerShell而不是C#来处理这些Sys Admin任务。



这是一篇关于如何使用它的文章PowerShell:



http://mcpmag.com/articles/2012/04/10/how-to-restart-computers-remotely-via-powershell.aspx [ ^ ]



http://myitforum.com/cs2/blogs/yli628/archive/2009/01/06/powershell-script-to-restart-multiple-remote-computers.aspx [< a href =http://myitforum.com/cs2/blogs/yli628/arch ive / 2009/01/06 / powershell-script-to-restart-multiple-remote-computers.aspxtarget =_ blanktitle =New Window> ^ ]



它实际上只是一个班轮:



I would personally use PowerShell instead of C# for these kind of Sys Admin tasks.

Here is an article on how to do this with PowerShell:

http://mcpmag.com/articles/2012/04/10/how-to-restart-computers-remotely-via-powershell.aspx[^]

http://myitforum.com/cs2/blogs/yli628/archive/2009/01/06/powershell-script-to-restart-multiple-remote-computers.aspx[^]

It's actually just one liner:

gc c:\Temp\ServerList.txt |%{Restart-computer –computername


_ -force}
_ –force}


以下链接可以帮助您



http:/ /stackoverflow.com/questions/19324738/shutdown-or-restart-machine-in-c-sharp-and-asp-net [ ^ ]



http://www.justskins.com/forums/want-to- reboot-server-65725.html [ ^ ]
Following links may help you

http://stackoverflow.com/questions/19324738/shutdown-or-restart-machine-in-c-sharp-and-asp-net[^]

http://www.justskins.com/forums/want-to-reboot-server-65725.html[^]


这篇关于重新启动服务器列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆