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:
- stop the service
- change the startname and password properties to "mydomain\username" and "password" respectively
- start the service
- 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