Filter services by log on as account with a domain user

rated by 0 users
This post has 3 Replies | 1 Follower

Not Ranked
Posts 2
ewbogue Posted: 04-25-2012 7:00 PM

I am looking for a way to obtain a list of services filtered by the log on as account being a domain user (vs. LocalSystem, for example). I do not see that Get-Service can access that information, but Get-WMIObject win32_service can. However, when I use this syntax I receive an invalid query error:

Get-WMIObject Win32_Service -filter "startname='domain\username'"

I tested this on the Application Identity Service by using this syntax to obtain the startname property:

Get-WMIObject Win32_Service -filter "name='AppIDSvc'" | fl *

The results show the property StartName with a value matching the domain\username I set in the Services Console.

Get-Help seems to indicate that I should be able to use any property to filter my results, but this is not working.

Ed

Not Ranked
Posts 2

Please try the following:

Get-WMIObject Win32_Service -filter "startname='domain\\username'"

should work. 

Top 10 Contributor
Posts 640

You beat me to it! The backslash is a special character in a WMI query; you escape it with a second backslash.

Not Ranked
Posts 2

Ah yes, the filter parameter requires WQL syntax. I was not aware of the \ character being special.

Thanks, it does work!

Page 1 of 1 (4 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.