Services all around
29/08/2012 Leave a comment
Hello Guys!
I’ve been pretty busy in theese days, you know, your family, your women….
So much things to do and so few time, so why logon every server in your farm and disable 20 services with your brand new Microsoft Wedge Touch Mouse, just before executing Exchange 2010 JetStress?
So, save on a file the name of the services you have to stop/start/disable/antomatically start and then:
Get-Content services_list.txt | % { $serv = gwmi win32_service -ComputerName (&hostname) -filter "name LIKE '$_'" write-host "Starting $_ ... " -nonewline $retu = ( $serv.startservice() ).ReturnValue # $retu = ( $serv.stopservice() ).ReturnValue # $retu = ( $serv.changestartmode("Disabled") ).ReturnValue # $retu = ( $serv.changestartmode("Automatic") ).ReturnValue Write-Host "$_ returned $retu" Start-Sleep 1 }
The Start-Sleep line is there to wait for some dependent services to stop properly.
See you!
AR