Reputation: 191
cannot understand why I can't stop a service with the powershell 'stop-service' as I can stop it with the 'net stop' command.
The service has one dependent service which is stopped (not a synchronization problem, I've tested 10 minutes after having stopped the dependent service).
Sorry for the french version of output...
PS C:\> stop-service pgsql-8.3
Stop-Service : Impossible d'arrêter le service « PostgreSQL Database Server 8.3 (pgsql-8.3) », car d'autres services en dépendent. Il peut être arrêté uniquement si l'indicateur Force est défini.
Au niveau de ligne : 1 Caractère : 13
+ stop-service <<<< pgsql-8.3
+ CategoryInfo : InvalidOperation: (System.ServiceProcess.Service
Controller:ServiceController) [Stop-Service], ServiceCommandException
+ FullyQualifiedErrorId : ServiceHasDependentServices,Microsoft.PowerShell
.Commands.StopServiceCommand
PS C:\> net stop pgsql-8.3
Le service PostgreSQL Database Server 8.3 s'arrête.
Le service PostgreSQL Database Server 8.3 a été arrêté.
The only way suggested by powershell is to force the stop. Is there a way to avoid this behaviour ?
Thanks in advance.
Denis
Upvotes: 1
Views: 6361
Reputation: 53
Stop-Service 'pgsql-8.3' -Force
Get-Service 'pgsql-8.3' -DependentServices | Stop-Service -Verbose
Get-Service 'pgsql-8.3' -DependentServices
Stop-Service 'pgsql-8.3' -Verbose
Start-Service 'pgsql-8.3' -Verbose
Upvotes: 1