<p>Vous pouvez utiliser WMI ou d’autres outils pour cela puisqu’il n’existe pas de cmdlet <code>Remove-Service</code> avant PowerShell 6.0 (<a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-service?view=powershell-6&viewFallbackFrom=powershell-5">Voir la doc Remove-Service</a>)</p>
<p>Par exemple :</p>
<pre><code class="lang-auto">$service = Get-WmiObject -Class Win32_Service -Filter "Name='servicename'"
$service.delete()
</code></pre>
<p>Ou avec l’outil <code>sc.exe</code> :</p>
<pre><code class="lang-auto">sc.exe delete ServiceName
</code></pre>
<p>Enfin, si vous avez acces a PowerShell 6.0 :</p>
<pre><code class="lang-auto">Remove-Service -Name ServiceName
</code></pre>