Windows PowerShell


Windows PowerShell Stop-Computer

PowerShell Stop-Computer Cmdlet

The PowerShell stop-Computer cmdlet is very similar to the operating system's built-in shutdown command.  A likely scenario is that you wish to down a remote server.  With a tiny substitution to the cmdlet's verb you could change the command so that it simply restart's that network computer.

Topics for PowerShell Stop-Computer

 ♣

Stop-Computer - Basics of Shutdown

Stop-Computer is handy for situations where you wish to shutdown a network server from the comfort of your chair, rather than long walk to the server room.  However, let us start by investigating PowerShell cmdlets containing the noun 'computer'.  If you don't see stop-Computer among the results this will remind you to get the latest version of PowerShell v 2.0.

get-Command -noun computer
# Results should include, stop, restart and add.
# Else, try $Host to check you have PowerShell v 2.0.

Researching Stop-Computer

Before we stop our first computer using a PowerShell command, it's well worth calling for help so that we can check the syntax and examine the parameters for stop-Computer.

get-Help stop-Computer -full

Note 1:  I like to append the -full switch so that I can see the examples.  Two interesting parameters revealed with help are -force and -credential.  It's also worth noting that stop-Computer uses WMI, hence there are possible firewall restrictions on this command.

Note 2:  In the case of stop-Computer, I can see many opportunities to add the -confirm switch.  Admittedly I reached this conclusion only after I had shot myself in the foot, and downed my local machine instead of the network server I was aiming at!

Simple Example of Stop-Computer

stop-Computer -computerName ExchServer

Example of Stop-Computer on Multiple Servers

$Victims ="SQLServer, ExchServer, GnomeServer"
stop-Computer -comp $Victims -force

Note 1: This example reboots multiple computers, the names of which are stored in a variable called $Victims.  You could extend this idea by employing get-Content to read the names of the servers stored in a text file.  Incidentally, I have shortened the parameter -computerName to -comp, in PowerShell you can shorten parameters so long as the truncated word is unambiguous.

Guy Recommends: SolarWinds LANSurveyorSolarwinds LANSurveyor

LANSurveyor will produce a neat diagram of your network topology.  But that's just the start; LANSurveyor can create an inventory of the hardware and software of your machines and network devices.  Other neat features include dynamic update for when you add new devices to your network.  I also love the ability to export the diagrams to Microsoft Visio.

Finally, Guy bets that if you take a free trial of LANSurveyor then you will find a device on your network that you had forgotten about, or someone else installed without you realizing!

Download a Free Trial of LANSurveyor

Problems with Stop-Computer

  • Error Message: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
  • Cause:  Firewall blocking the WMI / RPC command.
  • Solution:  Turn off the firewalls, alternatively, open just the RPC ports 135 and 445.

Summary of Windows PowerShell Stop-Computer

Stop-Computer is very similar to the old shutdown command which has been built-in to generations of Windows operating systems.  The advantage of stop-Computer is that it's simpler than remembering whether you need a switch such as -s or -r, furthermore the backslashes can be troublesome with the shutdown command.

See more PowerShell examples for Shutdown commands

PowerShell Home  • Syntax  • Stop-Computer  • Restart Computer  • Get-Credential

Please write in if you see errors of any kind.  Please report any factual mistakes, grammatical errors or broken links, I will be happy to not only to correct the fault, but also to give you credit.

Download my ebook:Getting Started with PowerShell
Getting Started with PowerShell - only $9.25

You get 36 topics organized into these 3 sections:
   1) Getting Started
   2) Real-life tasks
   3) Examples of Syntax.

In addition to the ebook, you get a PDF version of this  Introduction to PowerShell ebook  It runs to 120 pages of A4.

 *


Google

Web  This website

Review of Orion NPMGuy Recommends: Orion's NPM - Network Performance Monitor

Orion's performance monitor is designed for detecting network outages. A network-centric view make it easy to see what's working, and what needs your attention.

This utility guides you through troubleshooting by indicating whether the root cause is faulty equipment or resource overload.

Download a free trial of the Network Performance Monitor

 

Home Copyright © 1999-2009 Computer Performance LTD All rights reserved

Please report a broken link, or an error.