Question

I am a newbie in powershell script. I want to uninstall a service on remote machine and re-install it again. I am able to stop the service, change the files that service is using and again start it. But, now I want to completely uninstall it.

One more thing, I will be executing these scripts via TeamCity.

I have tried following ways, but each one is giving trouble:

  • using wmi class
  • running installutil command on remote machine. But, cant execute this on remote machine since there is problem in accessing that service.
  • Using Get-WmiObject command and then calling delete() on retrieved service.

Is there any promising solution ?? Any help will be appreciable..

Was it helpful?

Solution

After playing a lot with TC and many commands, finally I got my answer to uninstall a service on remote computer, and its working properly.

I have made use of "wmic" command and provided the remote computer name, username and password for /node:, /username:, and /password: parameters. And, provided 'installutil.exe' command to be executed remotely. Here, the actual command is..

"wmic /NODE:$serverName /USER:$userName /PASSWORD:$password process call create '$path_to_installutil_exe\installutil /u $exe_location_path_of_service'"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top