Thursday, October 14, 2010

Remotely Start/Stop Services Powershell

After some work and a whole lot of searching, I have found a script that will start and stop services using PowerShell.

I have been told that Powershell 2.0 has better options to do this but I have yet to locate it. Alot of people are stating "You can do that in PS 2.0 way easier.." Really HOW??? I have yet to see a post on how to do it...

Anyway here's the script:

$list = Get-Content "Location of List\list1.txt"
foreach ($s in $list)
{
(gwmi win32_service -computername $s -filter "name=''the service name").stopservice()
}

You can also use '.startservice()' at the end of line in the loop to start the service.

Quick, easy and to the point.

-Boston Tech Guy out.