To uninstall a Windows service on Windows Server 2022 using PowerShell, follow these steps:
-
Open PowerShell with Administrative Privileges:
- Click on the Start menu.
- Type
PowerShell
. - Right-click on
Windows PowerShell
and selectRun as administrator
.
-
Identify the Service Name:
- First, you need to know the service name (not the display name) of the service you want to uninstall. You can list all services and find the one you need by running:
Get-Service
- Note the
Name
of the service you want to uninstall.
- First, you need to know the service name (not the display name) of the service you want to uninstall. You can list all services and find the one you need by running:
-
Stop the Service:
- Before uninstalling, you need to stop the service if it is running:
Stop-Service -Name "ServiceName"
Replace
"ServiceName"
with the actual name of your service. - Before uninstalling, you need to stop the service if it is running:
-
Uninstall the Service:
- Use the following command to uninstall the service:
sc.exe delete "ServiceName"
Replace
"ServiceName"
with the actual name of your service. - Use the following command to uninstall the service:
Here’s a summary of the commands you might run:
# Open PowerShell as administrator # List all services Get-Service # Stop the service (replace "ServiceName" with the actual service name) Stop-Service -Name "ServiceName" # Uninstall the service (replace "ServiceName" with the actual service name) sc.exe delete "ServiceName"
After running these commands, the service should be uninstalled from your Windows Server 2022.