Yesterday I did a blog post where I discussed a problem with 2 Build agent versions. To avoid this issue in the future, I decided to upgrade both agents to the same version.
I tried to remove the build agent using .\config remove but for an unknown reason it failed and I ended up in a state where the agent was partially removed. When I tried to create a new agent with the same name it failed because the old windows service still existed.
To make a long story short, I had to do some cleanup work and removed the windows service manually using the following command:
sc delete vsoagent.tfs.AgentXXX
If everything goes correctly, you should see the following message:
[SC] DeleteService SUCCESS
Some more information about the sc tool can be found here: https://ss64.com/nt/sc.html