Disable Microsoft FTP Service (FTPSVC) using PowerShell

The Microsoft FTP Service (FTPSVC) is a built-in feature in Windows that allows users to set up and manage an FTP server on their system. However, there may be situations where you want to disable the FTPSVC using PowerShell.

 

$ServiceName=”FTPSVC”
if (Get-Service $ServiceName -ErrorAction SilentlyContinue) {
Stop-Service $ServiceName
Set-Service $ServiceName -StartupType Disabled
echo “The service $ServiceName has been disabled.”
}
else {
echo “The service $ServiceName is not installed.”
}

First, the variable $ServiceName is set to “FTPSVC”. This is the name of the service we want to work with.

Next, the code checks if the service exists by using the Get-Service cmdlet and passing the $ServiceName as a parameter. The -ErrorAction SilentlyContinue parameter is used to suppress any error messages if the service is not found.

If the service is found, the code proceeds to the if block. It first stops the service using the Stop-Service cmdlet with the $ServiceName as the parameter. This command stops the service if it is currently running.

Then, the code sets the startup type of the service to “Disabled” using the Set-Service cmdlet. This ensures that the service won’t start automatically when the system boots up.

Finally, it prints a message using the echo command to inform the user that the service has been disabled.

If the service is not found, the code jumps to the else block and prints a message indicating that the service is not installed.

Leave a comment

Your email address will not be published. Required fields are marked *

eight − 5 =