freefall: that was the problem I was having too. Still can't make it work, dunno why it works for some but not us. =(
moose: The problem is, that osfullname is not a property of the VM object, I have to Get-VMGuest after the Get-VM in order to check the OS type. That's why I need help - how can I look inside the Guest object, check if its windows, then pop back out to the VM object, since Get-View needs to be piped a VM object (not a VMGuest object)?
I see now. I didn't test it out before, I just assumed. How about this one, though? This worked for me.
$updList = get-cluster -name "DMZ-AMD-CLUSTER"|get-vm | where-object {$_.powerstate -eq "PoweredON"} | % {get-view $_.ID} |where {$_.guest.toolsstatus -match "toolsOld" } | where {$_.guest.guestfamily -match "windowsGuest"}
I am wondering if the problem with the script not always working has to do with the version of Windows Installer on the VM. JP1690's script arguments should work for the newest version, but I think old versions of installer use /reboot=reallysuppress
I had run into similar issues with trying to update tools with Powershell, so I came up with a version that uses more of a batch script and then psexec to execute it on remote machines. It requiers a little bit of setup but is very easy to pull of once its all set.
First, you'll want to put the list of VM's you want to upgrade (Windows only) in a text file. (list.txt)
===== list.txt =====
VM1
VM2
VM3
etc...
===== /list.txt =====
You'll want to copy the VMtools install files to a network share that all computers can access. You can get these by mounting the VMTools in the VM and copy all the files off the mounted cdrom.
Now, you'll want to create the batch file that will run on each computer. (vmtools.bat)
===== vmtools.bat =====
location_of_tools\setup.exe /s /v"/qn REINSTALLMODE=voums REINSTALL=ALL REBOOT=REALLYSUPRESS"
===== /vmtools.bat =====
Make sure list.txt and vmtools.bat are in the same directory and run the following command from that directory:
===== CMD =====
psexec @list.txt -d -u -c vmtools.bat
===== /CMD =====
This will copy the vmtools.bat to the remote computer and then run it. Make sure you run this from a DOS/CMD window and not a Powershell prompt. Powershell will attempt to interpret the @ and will prevent the command from running properly.
Automated VMware Tools upgrades using your VC and Perl
This does the same thing as the PowerShell examples shown.
PowerShell MVP, VI Toolkit forum moderator
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org
In the blog of laspina is told following:
This did not address any Linux or Unix systems so here is what I came up with to address the lack of automation
Did anyone open a feature / support request for an updated Update-Tools cmdlet ?
I've logged it.
I've used the standard MSI method to supress a VMware Tools reboot (REBOOT=ReallySupress) for a while now since I use Altiris to schedule the install and reboot. Beware though, the upgrade of VMware Tools will still do a NIC reset inside the VM causing a possible service failure!
In the following overview, I put together which vmware tools upgrade cases we have now with esx 3.5 update 3.
This a service view. A special case is the Upgrade of Vmware Tools, when an existing ESX Server Cluster is replaced with new ESX Server, where the EVC Option
could only be actived, when all VM's in a cluster have be shutdowned for activating EVC in a DRS Cluster.
Allthough in the next Version of Vmware Update Manager this would be a good to have it.
Which Powershell exists already for this above overview
description | function | todo | script | |
without reboot switch in cmdlet | "ReallySuppress" | fix by vmware | ||
check for vmware tools version | check version | http://www.yellow-bricks.com/2008/04/21/powershell-vi-toolkit/ | ||
case 1 upgrade one vm | upgrade | cmdlet | ||
case 2 upgrade per t.xt file | upgrade | read from csv | ||
case 3 upgrade per cluster | upgrade | in this thread | ||
case 4 upgrade resource pool | upgrade | in this thread | ||
set hardware acceleration | config change of vm | http://www.peetersonline.nl/index.php/vmware/setting-video-hardware-acceleration-level/ | ||
"UpgradeAtPowerCycle" | config change of vm | http://www.vmachine.de/cms/index.php/de/downloads?task=files.download&cid=3 http://tech.zsoldier.com/2008/11/powershell-script-to-enable-check-and.html | ||
shutdown all Vm's | shutdown vm |
Using all the permutations of various $insParm configs, I still cannot get the VMtools installer not to pop up the dialog box at the end saying Yes/No to a reboot which eventually times out and reboots the machine. I think the problem may be that the Tools' setup.exe is the part of the installer causing this reboot, so passing these parameters to the MSI that's chained off of it isn't going to do us any good. We need a switch for the actual tools installer which says to forgo a reboot. Does anyone know of one?
I suppose building this into the Upgrade-Tools cmdlet would be ideal, though... has there been a response to your feature request?
We plan to add this feature, but if the problem you have is in the tools installer itself that's going to make it quite a bit harder. Do you get the same results if you run it in the guest directly using those switches?
Results:
"C:\Program Files\VMware\VMware Tools\VMwareToolsUpgrader.exe" -p "/s /v\"/qn /norestart\""
FAILED (system rebooted)
Mount VMware Tools CD and run:
msiexec /i "D:\VMware Tools.msi" /qn REBOOT=ReallySuppress REINSTALL=ALL REINSTALLMODE=VOMUS
SUCCESS (no reboot)
Mount VMware Tools CD and run:
setup.exe /S /v"/qn /norestart REBOOT=ReallySuppress REINSTALL=ALL REINSTALLMODE=VOMUS"
SUCCSES (no reboot)
if I set $insParm = '/S /v"/qn /norestart REBOOT=ReallySuppress REINSTALL=ALL REINSTALLMODE=VOMUS"'
FAILURE (vm reboots)
so something with Powershell is not working here.
EDIT: Also tested
"C:\Program Files\VMware\VMware Tools\VMwareToolsUpgrader.exe" -p "/S /v\"/qn /norestart REBOOT=ReallySuppress REINSTALL=ALL REINSTALLMODE=VOMUS\"'
FAILED.
So either the problem is PowerShell or that PowerShell is using VMwareToolsUpgrader on the backend, which doesn't support the noreboot option or at least that option is undocumented.
The old way, like you describes works.
I would like to have a powershell script which runs at "Hosts & Clusters" level.
What the script should do:
Install VMware Tools whitout reboot on VMs which have "OldTools" or "Tools not Installed"
This script didnt work for me:
$insParm = '/s /v"/qn /norestart"'
$updList = get-cluster -name "My_Cluster_name"|get-vm | where-object {$_.powerstate -eq "PoweredON"} | % {get-view $_.ID} |where {$_.guest.toolsstatus -match "toolsOld" } | where {$_.guest.guestfamily -match "windowsGuest"}
{
$uVM.name
$uVM.UpgradeTools_Task($insParm)
Any help would be appreciated
May it be that the method "UpgradeTools_Task()" is not anymore included to the actual toolkit (1.5)?
I'll get this error:
VirtualMachineImpl] doesn't contain a method named 'UpgradeTools_Task'.
At :line:14 char:23
+ $uVM.UpgradeTools_Task <<<< ($insParam)
UpgradeTools_Task is a method of the VirtualMachine object.
This is an SDK object not a VITK object, so in principle has nothing to do with the VITK.
It looks as if the $uVM variable doesn't contain a VirtualMachine object.
You can check the object type with
$uVM.GetType()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The Object has the type "VMware.VimAutomation.Client20.VirtualMachineImpl", and get-member shows me there is no such method.
Now I'm a bit confused, I thought the script from jp1960 is for powershell ??