Systematic reinstallation of agent

I’m in the process of reinstalling the agent on several PCs that I think failed the upgrade process to the 10.x agent (from what I can gather in the log files). In doing so I am copying the BESRemove10.0.3.66.exe tool and running the command remotely via psexec to silently remove it. During this process I have noticed that some exit out with 0 indicating success however when I check further I find that it was unsuccessful due to not being able to kill the besclient.exe service. So I was thinking about automating the process of removal and reinstallation but first was wondering if anyone has already tackled this. Specifically I was thinking the sequence should be:

  • Ping computer to confirm it is online
  • Determine if \computername\C$ is accessible remotely
  • Copy needed setup and removal utility files to remote computer
  • Force kill the besclient.exe process
  • Run besremove.exe and wait until exit
  • Run setup.exe silently

Thoughts on the order of operations and if I am missing anything? I would presumably run it against a text file list of offline computers I find in the BigFix console.