I can use this to get which services run with this account:
Get-WmiObject “win32_service” -Filter “StartName=‘domain\user’”
Where I’m stumped is how to put the services into an array so I can loop through the array and stop the services and of course then restart the services.
Alternatively how could I use something like this to get the services??
$Services = Get-WmiObject Win32_Service -ComputerName “.” | Where { $_.name -eq ‘MSSQLSERVER’ } – this is the general idea
to become something like – this is almost what I need but I don’t know how to construct the where part to properly query the start name of the service(s):
Would be more efficient. And you can filter based on StartName the same way. You only use the double backslash when querying the way I’ve done here. If you’re using Where-Object, then you’d use a single backslash. The double backslash is a WMI-specific escape sequence, not needed for filtering at PowerShell itself.
Richard Siddaway wrote a lovely book on WMI and PowerShell, if you plan to mess with this stuff a lot. A lot of good tips and a ton of “how it works.”
Thank you, now I must learn how to change the password for that service account.
The above array can be used to stop and start the services running with that account.
Thank you, Tom