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
Please try the following:
Get-WMIObject Win32_Service -filter "startname='domain\\username'"
should work.
You beat me to it! The backslash is a special character in a WMI query; you escape it with a second backslash.
Ah yes, the filter parameter requires WQL syntax. I was not aware of the \ character being special.
Thanks, it does work!