I\'m working on removing an agent from a pool temporarily, install new software on the buildserver the agent is on, test that it works, and then add the agent to the pool again.
There is no such API to create or remove an agent from the agent pool. And it's not needed to write your own script. When you download the agent, you just need to run a command prompt as Administrator, and then run ConfigureAgent.cmd
on your build agent machine:
C:\Agent\ConfigureAgent.cmd
Then respond to the prompts. Check Deploy an agent on Windows for TFS 2015