Brandon
Brandon

Reputation: 771

Get Associated Application of a Disabled / Stopped Service

Problem

I am working with a PowerShell script to skim through a lists of known application services and, for any that are disabled, the script is expected to uninstall them. I have been researching how to get the application name/path of a target service, but failed to find anything suitable to my needs. I had tried working with Get-Service in hopes of that getting me what I need, but was not able to get the desired results.

Question

How do I get the associated application of a target service that is currently stopped or disabled using PowerShell?

PS: Please understand that PowerShell is a requirement of this.

Upvotes: 0

Views: 149

Answers (1)

Mark Wragg
Mark Wragg

Reputation: 23355

The running state of the service shouldn't really impact what information you get back. However Get-Service doesn't give you all of the configuration info for a Service, in particular the Path of the process being invoked.

To get that you can use Get-WMIObject Win32_Service. For example:

Get-WMIObject win32_service | Where {$_.name -eq 'wuauserv'} | Select *

This returns a PathName property amongst others that I think you will find useful.

Upvotes: 2

Related Questions