- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to stop service with their dependent services in PowerShell?
To stop the service which has dependent service in PowerShell -Force parameter is used. First, we will check what are the dependent services for specific service, to get them -DependentService parameter is used.
Example
For example, WMI service (Name: Winmgmt) has multiple dependent services.
Get-Service -Name Winmgmt -DependentServices
Output
tatus Name DisplayName ------ ---- ----------- Running UALSVC User Access Logging Service Stopped smstsmgr ConfigMgr Task Sequence Agent Stopped SepLpsService Symantec Endpoint Protection Local ... Stopped NcaSvc Network Connectivity Assistant Running iphlpsvc IP Helper Running CcmExec SMS Agent Host
Now, we will stop Winmgmt Service along with their dependent services with -Force parameter. To check the command process -verbose parameter is added.
Stop-Service -Name Winmgmt -Force -Verbose
With Displayname,
Stop-Service -DisplayName "Windows Management Instrument" -Force -Verbose
Another way to stop the dependent service is to get the dependent services first and then pipeline Stop-Service parameter and you don’t need to use -Force parameter this time, but this will only stop the dependent services, not the service which is specified.
Get-Service Winmgmt -DependentServices | Stop-Service -Verbose
The above command will stop the dependent services of Winmgmt but not itself.
To Continue Learning Please Login
Login with Google