How can I extract "Path to executable" of all services with PowerShell -


get-service *sql* | sort displayname | out-file c:/servicelist.txt 

i have 1 line powershell script extract list of services running on local machine, now, in addition displaying "status", "name" , "displayname" want display "path executable"

i think you'll need resort wmi:

get-wmiobject win32_service | ?{$_.name -like '*sql*'} | select name, displayname, state, pathname 

update if want perform manipulation on selected data, can use calculated properties described here.

for example if wanted text within quotes pathname, split on double quotes , take array item 1:

get-wmiobject win32_service | ?{$_.name -like '*sql*'} | select name, displayname, @{name="path"; expression={$_.pathname.split('"')[1]}} | format-list 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -