To restart multiple computers with PowerShell and without relying on functionality of the remote operating system, you can use the PCSVDevice module. The module contains several useful cmdlets for out-of-band management and supports the IPMI protocol.

Sometimes you have to shut down a large number of servers due to outages, or you have to restart multiple servers synchronously because of an update to an interdependent application. Out-of-band management is one method we can use to do this.

Out-of-band management with PowerShell ^

Out-of-band management allows system administrators to access servers via protocols such as the Intelligent Platform Management Interface (IPMI) to perform actions outside of the operating system (OS) a server is running. Using IPMI takes place via a baseboard management controller (BMC) that can be integrated into or separate from the motherboard on a system.

For instance, if a server is powered off and you would like to power it back on, you can use IPMI to send a "power on" command as long as there is a network connection online to the BMC. Examples of BMCs are the Integrated Dell Remote Access (iDRAC) or HP Integrated Lights Out (iLO) cards. While this technology is not new, PowerShell actually has a module, Pcsvdevice, specifically designed for out-of-band management.

PcsvDevice cmdlets ^

To see what cmdlets are available, we use Get-Command:

Displaying the cmdlets of the PcsvDevice module

Displaying the cmdlets of the PcsvDevice module

Start-PcsvDevice, Stop-PcsvDevice, and Restart-PcsvDevice are all self-explanatory, but some other interesting cmdlets are part of Windows 10/Server 2016. For instance, to set the network configuration of the IPMI interface, we can run:

Booting and powering off systems ^

In this first example of Start-PcsvDevice, I am going to boot up a physical host running VMware ESXi. This Dell server has an iDRAC interface and is currently powered off. Notice I specify IPMI as the management protocol I use to communicate with the systems. You can also use the Web Services Management (WS-Man) protocol, though I will be using IPMI exclusively in this article.

To power down a system, we use the same parameters with Stop-PcsvDevice:

Restarting multiple servers ^

Now in this example we want to automate the restarting of multiple servers in our data center. Keep in mind, the beauty of out-of-band management is that the OS installed on a server is irrelevant. So regardless of whether a server is running Windows or Linux, we can use these same cmdlets to power them on.

I have configured the same IPMI user account on each server, so I will be able to authenticate with the same $Credential variable in PowerShell.

First I will put the hosts in a variable, $Computers. I will then use Restart-PcsvDevice with the Foreach-Object cmdlet to boot all of the servers. It would be helpful to have a data source I could query that would provide a dynamic value for all the physical hosts I need. So in this example I will use Get-ADComputer to query all hosts in a particular organizational unit (OU) called "Physical Servers."

Now I will pipe the values in $Computers to the Foreach-Object cmdlet to boot all the hosts. Note I add "-IPMI" to the target address since these iDRAC interfaces refer to the production hostname of the server with -IPMI added:

Conclusion ^

Although many organizations are pushing their systems to the cloud, for most, a hybrid setup will be the norm for the foreseeable future. Managing on-premises systems means you need to prepare for unforeseen occurrences that can cause power outages. You may need to power off hundreds or thousands of servers and power them back on quickly due to outages. Out-of-band management is one method you can use to do this.

In addition, the cmdlets of the PCSVDevice module come in handy whenever you have to shut down or restart multiple computers without relying on the operating system of the remote systems.

Join the 4sysops PowerShell group!

Your question was not answered? Ask in the forum!

0
Share
0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2020

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account