Windows PowerShell Stop-ComputerPowerShell Stop-Computer CmdletThe 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 ShutdownStop-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 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-Computerstop-Computer -computerName ExchServer Example of Stop-Computer on Multiple Servers $Victims ="SQLServer, ExchServer, GnomeServer" 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 LANSurveyor
|
||||||
Download my ebook:
|
*
|
|
|
|
Home Copyright © 1999-2009 Computer Performance LTD All rights reserved Please report a broken link, or an error. | |