scnguye2
Contributor
Contributor

Script - VMware Tools Upgrade on multiple VMs

Can anyone help? I found the script below on another discussion and need some help trying to create .bat files. I have some questions regarding procedures to upgrade

VMware Tools on muliple VMs: (I am really new to .bat file and

scripting, so please feel free to give me the layman's term explanation)

Please refer to the script below these questions:

1. How many .bat files do I need to create?

(I see a VMT.bat, which maps the network share, but what did you call the second .bat file)

2. Where should I store both of these .bat files?

3. Where do I execute these files from?

4. Will this procedure restart each VM when it is finished? I do NOT want the script to restart the VM after the upgrade.

Any help is truly appreciated. Thanks in advance.

SCRIPT:

Thanks Everyone. Finally I got the script working. I created following script named VMT.bat -

net use K: "\Network Path to VMware Tools" password /USER:domainname/username /PERSISTENT:no

msiexec -i "K:\vmware tools.msi" addlocal=all /qn REINSTALLMODE=vamus REINSTALL=ALL REBOOT="ReallySuppress"

Using another bat file (text mentioned below) I copied above

script(VMT.bat) and ran it to all the VMs (names were saved in another

file called servernames.txt which was in the same directory as of below

script) on which Vmtools were need to be updated -

@ECHO OFF

:: Batch File at Remote Server

::

set _comp=servernames.txt

set _rpt=Report.txt

echo Ran at %date% %time% > %_rpt%

echo. >> %_rpt%

for /f %%a in (%_comp%) do call :Task %%a

exit /b

:Task

ECHO CHECKING %1

ECHO %1 >>%_rpt%

start psexec \%1 -c "\network path to vmt.bat created above"

sleep 1

exit /b

Please note that the psexec.exe and servernames.txt needs to be copied

into the same directory as of above script to copy and run VMT.bat to

all the servers.

I ran this script using my domain admin account and all the servers

were in the same domain so there were no access issues. Everything

worked fine and for confirmation I checked application logs which were

showing VMware tool configured successfully.

0 Kudos
3 Replies
mikefoley
VMware Employee
VMware Employee

Have you considered using PowerCLI to do this? Here's a pointer to a script http://get-admin.com/blog/?p=714

mike

mike
0 Kudos
scnguye2
Contributor
Contributor

After working with VMware Tech Support and some individual test, the following WORKED for me:

Power CLi script - Upgrade VMware Tools on Multiple VMs in a Folder WITHOUT REBOOT

Create a new folder in vCenter

Place VMs with "OLD" VMware Tools into the folder

Install Windows Powershell

Install VMware Power CLi 4.0 Update 1

http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli?ie=utf-8&oe=utf-8&aq=t...

Open VMware vSphere PowerCLI and run command: "Set-ExecutionPolicy Unrestricted"

Create a new .ps1 file with the following code:

Connect-VIServer -server <vCenter server name> -user <name> -password <password>

$insParm = '/S /v"/qn REBOOT=ReallySuppress"'

$updList = get-folder -name vmtools| get-vm |

where-object {$_.powerstate -eq "PoweredON"} | % {

get-view $_.ID } |where { $_.guest.toolsstatus -match "toolsOld" } |

where {$_.guest.guestfamily -match "windowsGuest"}

foreach ($uVM in $updList)

{

$uVM.name

$uVM.UpgradeTools_Task($insParm)

#Wait 300 (5min) seconds before starting another update task

Start-sleep -s 300

}

Save the file, <name>.ps1 to <C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts>

Type .\<name>.ps1, at the CLi prompt

<screenshot>

Observe vCenter "initiating the VMware Tools install or upgrade" task. Upon task completion, check the VM Summary tab to make sure that the VMware Tools status shows: OK

On a separate note. Here is a third-party tool for quick VMware Tools install on multiple VMs (WARNING - REBOOT will OCCUR!!!)

Note:

This tool is all EXPERIMENTAL and NOT officially SUPPORTED by VMware

0 Kudos
rborgmaster
Contributor
Contributor

Is it really OK to update the VMtools without rebooting after?

0 Kudos