Verifier si un service Windows existe et le supprimer dans PowerShell
Source : Stack Overflow [powershell]
Verifier si un service Windows existe et le supprimer dans PowerShell
Source : Stack Overflow [powershell]
Vous pouvez utiliser WMI ou d’autres outils pour cela puisqu’il n’existe pas de cmdlet Remove-Service avant PowerShell 6.0 (Voir la doc Remove-Service)
Par exemple :
$service = Get-WmiObject -Class Win32_Service -Filter "Name='servicename'"
$service.delete()
Ou avec l’outil sc.exe :
sc.exe delete ServiceName
Enfin, si vous avez acces a PowerShell 6.0 :
Remove-Service -Name ServiceName