Wow, First I think that was the longest title I have had thus far for a blog post.  Anyway, when updating/upgrading VMware Tools with VMware Update Manager the error I run into the most is just that VMwareToolsUpgrader.exe needs to be deleted from the target pc.

I always get very annoyed when I go to upgrade a large batch of VMs and half of them fail because of that file. So recently I wrote a quick that I will be running beforehand from now on to delete that file so i don’t have to deal with it…hopefully. I also know that this is a common issue that a lot of people have which is a another reason why I wanted to write the script.

#Delete Tools
param([string]$location="*", [switch]$errors)

$vms=get-vm -location $location | ?{$_.powerstate -like "*on"}
ForEAch ($vm in $vms)
	IF((get-vm $vm|get-view) -notlike "*1234*")

		IF((test-path "\$namec$windowstempVMwareToolsUpgrader.exe") -eq $true) {
			Write "Deleting \$namec$windowstempVMwareToolsUpgrader.exe"
			remove-item $item -ea stop
			Catch {Write "Error deleting $item"; $out+=$item}

		IF((test-path "\$namec$windowstempvmware-SYSTEMVMwareToolsUpgrader.exe") -eq $true){
			Try {
			Write "Deleting \$namec$windowstempvmware-SYSTEMVMwareToolsUpgrader.exe"
			remove-item $item -ea stop
			Catch {Write "Error deleting $item"; $out+=$item }

"Could not delete the following files:"

Couple quick notes about the script:

By default it will search all the VMs of the vcenter/server you are attached to. However I put the $location parameter in there in case you want to just do the VM in a given folder/datacenter or wherever.

The $errors switch parameter is in there in case you would like to also have all the errors it came across repeated back to you in one lump sum at the end. Which would be useful if you have a lot of VMs this would be running on and you didn’t want to pay attention to which ones fail while the script is running. You could also output it to a file if you wanted, but I didn’t include it in this version.

LINE 8:  You will see I put in a check for a specific VMTools version number. If you wanted you could enter the current or most up to date version number in there and it will skip those VM’s, OR as I have it, you can just have a bogus number in there so it will try to delete the file from everyone.

This should also be obvious from the script, but this uses DNS, so if you have dns issues you may see problems with this script. Also you would need rights to delete the file on VM as well.

Anyway I hope this helps. Let me know what you think!


Leave a Reply