I was looking up how to start a service and it's dependent services, and I was reading this site .
It has an example:
get-service lanmanserver | Foreach { start-service $_.name -passthru; start-service $_.DependentServices -passthru}
However, when I run the above cmdlet, I get the error:
Start-Service : Cannot find any service with service name 'System.ServiceProcess.ServiceController'.
Does anybody know why I'm getting this error? Also, I've been using a different way to start a service and it's dependencies:
get-service lanmanserver | select -expand DependentServices | start-service
Any feedback on the workaround?
Thanks!
This start-service $_.DependentServices
returns a collection of services and you're passing it to Start-Service
as an argument for the Name
parameter (default parameterset's 0th position parameter). Try this instead:
... Start-Service -InputObject $_.DependentServices -passthru ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.