in

WindowsWindows Loving ItLoving It

Shut Down yours and multiple remote computers using PowerShell

You can easily shut down your local computer with just one command. You can also shutdown other computer using a switch, & multiple server using variable

shut down using PowerShell

Let us see the PowerShell stop command for shutting down our computers.  We have to use the simple Stop-Computer command to shutdown the computer.  If you are looking to shut down the remote computer, you can just use the same command.

Jump to:

Shut down the computer using Stop-Computer command:

  • Press the start button.
The start menu
The start menu
  • Type PowerShell and choose the application shown in the image.
PowerShell
PowerShell
  • Enter the following command.
stop-computer
stop-computer
stop-computer
  • PowerShell is case insensitive so the above command must work without a problem.
  • The previous command will shut down the computer in which the PowerShell terminal is running.
  • We can shut down the remote computer by using the remote computer name as shown in the command below.
stop-computer -computername <RemoteComputerName>
shut down server
shut down server
  • Here replace the <RemoteComputerName> with the name of your remote computer.
  • Note that the command will shut down the remote computer named TecKangarooWindowsServer.

Stop Multiple Remote Computers/Server using PowerShell

We can stop multiple computers using the same PowerShell command.  For this, we will use a PowerShell variable to save the names of all the remote computers and shut them down using the same variable name.  Follow the below steps for shutting down multiple computers.

  • Create a variable with multiple servers as shown in the image.
$AllServers = “TecKangarooServer1, TecKangarooExchangeServer, TecKangarooMSSQLServer”
Power Shell variable
Power Shell variable
  • We are creating a variable and saving the necessary server names in it.
  • Please note that you need to provide your server names in order for it to work for you.
  • Use the stop-computer command for shutting down the computers.
stop-computer -computername $allservers
shut down multiple computers
shut down multiple computers

Restart Computer using PowerShell:

In this bonus section, we will see how to restart the computer instead of shutting down.  The command is easy because we have to only replace the shut down with restart.

restart-computer -computername <RemoteComputerName>

Replace the <RemoteComputerName> with the name of the computer that you want to restart.

Conclusion:

It is easy to shut down a computer using the PowerShell command.  The user have to use only the shut-down command along with the -computername switch for specifying the computer name.  In the case of multiple computers, suitably multiple remote computers, we can use the PowerShell variable to store up all the names in one variable and pass the variable to the command.

We can replace the shut-down command with restart-computer to restart the computer.

For more such awesome posts, stay tuned to TecKangaroo.

Leave a Reply

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