Security Basics mailing list archives
Re: Scripting to disable services
From: krymson () gmail com
Date: 19 Sep 2007 18:03:04 -0000
You want to learn PowerShell, right? Sure ya do! This script sample requires you install PowerShell. You can also get some other information near what was posted previously [1]. As a disclaimer, this script has no error checking and no process to check if a server is up before iterating through all the services, so it can throw lots of errors. Use at your own risk, and on test systems first. Obviously you need some demi-god or god rights on the target systems. I have no tested this script snippet. Edit the obvious two variables. Save as File.ps1. execute it in PowerShell from the directory you saved it in as ./File.ps1. $arrServers = "SYSTEM1,SYSTEM2,SYSTEM3".Split(",") $arrServices = "service1,service2,service3".Split(",") foreach ($system in $arrServers){ foreach ($service in $arrServices){ $targetservice = gwmi win32_service -computer $system | ? {$_.name -match "$service"} $targetservice.StopService() $targetservice.ChangeStartMode("DISABLED") } } Earlier caveats remain in users being able to just re-enable the services, but that wasn't your question, so, enjoy turning services on and off en masse! <- snip -> I'm trying to find a way to script a mass disable of services on a series of standalone WinXP SP2 boxes. I need to be able to be run it locally under admin, without installing additional software (i.e. default XP SP2). Need to disable about 25 services.
Current thread:
- Scripting to disable services twofish (Sep 18)
- Re: Scripting to disable services Ansgar -59cobalt- Wiechers (Sep 19)
- Re: Scripting to disable services Kurt Buff (Sep 19)
- Re: Scripting to disable services Brian Johnson (Sep 19)
- RE: Scripting to disable services peter.schaub (Sep 19)
- Re: Scripting to disable services Robert Bauer (Sep 19)
- RE: Scripting to disable services Murda Mcloud (Sep 19)
- Re: Scripting to disable services Pranay Kanwar (Sep 19)
- <Possible follow-ups>
- Re: Scripting to disable services jfvanmeter (Sep 19)
- Re: Scripting to disable services krymson (Sep 19)
- Re: Re: Scripting to disable services jason . gerfen (Sep 19)
- Re: Scripting to disable services Ansgar -59cobalt- Wiechers (Sep 20)
- Re: Scripting to disable services krymson (Sep 19)