Hi all,
I am using the following script to update my VMs Tools:
It works fine with Windows 2008 R2, but when I want to update Windows 2003 R2, it just hangs at "Initiated VMWare Tools Install or upgrade". But when I go into the VM, the CD is not even mounted.
What am I doing wrong?
Is there any information in the logs? It might happen that u get the error "TOOLS INSTALL Error copying upgrader binary into guest". If this is the case move or delete the following file: "C:\WINDOWS\Temp\VMwareToolsUpgrader.exe" and try again.
Does this provide additionial information or errors?
Where the tools running before? Are they still runing at the moment?
From which version are you upgrading to which?
Yes, they were running and still running... We patched recently our ESXi hosts and want the tools to match the host version. On the VM its 4.0.0 build-261974. The host is at 4.0.0 504850
Is there any information in the logs? It might happen that u get the error "TOOLS INSTALL Error copying upgrader binary into guest". If this is the case move or delete the following file: "C:\WINDOWS\Temp\VMwareToolsUpgrader.exe" and try again.
Does this provide additionial information or errors?
Worked like a charm. Now, I have to integrate a function to check for the file and then delete the VMwareToolsUpgrader.exe.
Thanks again! Points awarded
No problem, you might want to check out the "Invoke-VMscript" function to determine if the file exists or not.
This will not work. I do not have powershell on all my servers. The problem is access to the C:\Windows\Temp folder in order to delete the exe file. I can't seem to be able to access the file remotely and delete it.
anyways, lots of digging and testing to do...
thanks again
Can't you use the hidden share \\servername\C$ to delete the file?
You can also start a BAT file with Invoke-VMScript.
If the VMware Tools are already installed, you can launch a 'del' command to all of them.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Do I need to have powershell within the VM I need to run a bat file? Where would I need to put the bat file?
You can place the bat inside the VM. The VM doesn't need PowerShell. I suggest you lookup the function Invoke-VMScript (http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Invoke-VMScript.html).
You will have to refer to the path. There is an example on the page:
$script = '&"$env:ProgramFiles\Common Files\Microsoft Shared\MSInfo\msinfo32.exe" /report "$env:Tmp\inforeport"' Invoke-VMScript -ScriptText $script -VM VM -HostCredential $hostCredential -GuestCredential $guestCredential
No need for PowerShell in the VM to execute a BAT script.
And you do not need the BAT file to be copied to the VM first.
On the ScriptText parameter you pass the BAT lines.
See the Invoke-VMScript cmdlet help.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Awesome!! Exactly what I was looking for. Her is what I got:
Is there a way to have a prompt for credentials and passing it to all VMs in the csv. I tried removing GuestUser and Guest Password, but prompts at every server listed.
vmname,guestuser,password
vm1,administrator,mycoolpass
vm2,administrator,mysecondpass
I want to use one account (domain account with admin rights) and not have to put it in a file. I want it to be available for multiple users from tech support.
I am confused by your question. Since you are using a domain account the password should be the same everywhere?
Or do you want a prompt which asks for the username and the password and then do something ?
If this is the case you can try something like this:
Connect-VIserver -server 192.168.10.67
$username = Read-Host "Enter username:"
$password = Read-Host "Enter password:"
Import-CSV c:\1.csv | foreach {Get-VM $_.Name | Invoke-VMScript -ScriptType bat -ScriptText "del c:\Windows\temp\vminst.log" -RunAsync -GuestUser $username -GuestPassword $password}
exactly what I needed... I do have the tendency to vaguely express myself, but thanks for understanding. You guys are the best!