PowerShell Live - being retired

Please go to http://www.shelltools.net for more information

Welcome to PowerShell Live - being retired Sign in | Join | Help
Home Main Site Blogs Forums Videos Chat Customer Support

Using WMI and/or Get-Service / Set-Service to modify service properties

  •  07-19-2007, 1:35 PM

    Using WMI and/or Get-Service / Set-Service to modify service properties

    I've been playing with this a bit, but have had only limited success.  Let's say that I have a service "example-svc" which exists on multiple machines.  I want to take the following actions on this service on all machines on which it exists:

    1. stop the service
    2. change the startname and password properties to "mydomain\username" and "password" respectively
    3. start the service
    4. query the service's status

    I would think that I could do something like:

    $service = get-wmi win32_service | where { $_.name -eq 'example-svc' }

    $service.stopservice

    $service.change( , , , , , , "mydomain\username", "password" )

    $service.startservice

    $service.state

    The change command doesn't work for me, and I suspect it's the way that I'm using the commas.  Does anyone have any ideas?  TIA

    Filed under: ,
View Complete Thread