Hi anonymous user ,
you can try this:
$a=(gwmi win32_service|?{ $_.name -eq "service name"}).pathname
Split-Path -Path $a
Or all in one line:
$a = (gwmi win32_service|?{ $_.name -eq "servicename"}).pathname | Split-Path
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten