hi Is it possible to upgrade vm hardware and tools with one script?
I guess the vm would need to be shutdown before vm hardware upgrade and vmware tools will need to be upgraded before vm hardware.
I think the logic is
upgrade the tools while the guest is running.
Do not reboot
wait til the task is done then shutdown the guest
check the status on the guest to see if its shutdown
upgrade vm hardware
then start up guest
Try something like this
foreach($vm in Get-VM){
if($vm.ExtensionData.Guest){
if($vm.Guest.State -eq "running"){
if($vm.Guest.ExtensionData.ToolsStatus -eq "toolsOld"){
Update-Tools -VM $vm -NoReboot | Out-Null
while($vm.ExtensionData.Guest.ToolsStatus -eq "toolsOld"){
sleep 5
$vm.ExtensionData.UpdateViewData("Guest.ToolsStatus")
}
Shutdown-VMGuest -VM $vm
while($vm.ExtensionData.Runtime.PowerState -eq "poweredOn"){
sleep 5
$vm.ExtensionData.UpdateViewData("Runtime.PowerState")
}
if($vm.Version -ne "v10"){
Set-VM -VM $vm -Version v10 -Confirm:$false
}
Start-VM -VM $vm -Confirm:$false
}
else{
"$($vm.Name) Tools up to date"
if($vm.Version -ne "v10"){
Shutdown-VMGuest -VM $vm
while($vm.ExtensionData.Runtime.PowerState -eq "poweredOn"){
sleep 5
$vm.ExtensionData.UpdateViewData("Runtime.PowerState")
}
Set-VM -VM $vm -Version v10 -Confirm:$false
}
Start-VM -VM $vm -Confirm:$false
}
}
"$($vm.Name) appears to have no Tools installed"
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc,
I will give it a try. I assume this ill only work for windows guest vms and not linux right?
The script doesn't use any Windows specific features, so this should work for *nix as well.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Does this require VM's re-boot after running the script ?
thanks
vm2014
Yes, that is what the Start-VM is doing.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Can this script be modified so that VMware tools installed without re-boot or silently so that during schedule windows the VM will re-boot ? I want VMware tools upgrade with no re-boot.
thanks
vm2014
You can use the NoReboot switch on the Update-Tools cmdlet
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference