Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull physical path of a Windows Service using Get-Service command

I need to pull Physical Execution paths of all the Windows Services on a Set of Servers, that run on Win 2k8. As, the powershell version that is shipped with this OS is 2.0, I wanted to use Get-service command instead of Get-WmiObject. I know that I can pull the physical path using the command given below

$QueryApp = "Select * from Win32_Service Where Name='AxInstSV'"
$Path = (Get-WmiObject -ComputerName MyServer -Query $QueryApp).PathName

I donot want this command to pull the physical path but wanted to use Get-Service command that comes with PS Version 2.0.

Any help would be much appreciated.

like image 709
Varun Kumar Palavalasa Avatar asked Sep 25 '12 12:09

Varun Kumar Palavalasa


People also ask

How do I find the path of a Windows service?

The physical path is 'C:\WINDOWS\TEMP\.

How do I get the description of a service in PowerShell?

To find the service name and display name of each service on your system, type Get-Service . The service names appear in the Name column, and the display names appear in the DisplayName column.

How do I change the path of a Windows service?

To change the executable path of ServiceDesk go to below-mentioned location from registry. run -> regedit -> navigate to the below-mentioned location and highlight the ServiceDesk and from the right-hand side edit the ImagePath as required.

How do you find a service?

Press the Win + R keys on your keyboard, to open the Run window. Then, type "services. msc" and hit Enter or press OK. The Services app window is now open.


1 Answers

@alroc did good, but there's no reason to filter all services. Querying WMI is like querying a DB, and you can just ask WMI to do the filtering for you:

(Get-CimInstance Win32_Service -Filter 'Name = "AxInstSV"').PathName

To explore all of the meta available for that service:

Get-CimInstance Win32_Service -Filter 'Name = "AxInstSV"' | Select-Object *
like image 121
VertigoRay Avatar answered Sep 22 '22 15:09

VertigoRay