Hi,
I have wriitten the following script to update VMTools on my Windows VM's. The script is running fine but it is throwing the following error for each and every VM. However it is successfully updating the VMTools on the VM.
17/11/2019 05:11:05 Update-Tools Operation is not valid due to the current state of the object.
$report = @()
if($VM.ExtensionData.Guest.ToolsVersionStatus -eq "guestToolsNeedUpgrade"){
Write-Host "Updating VMware tools on $($VM)" -ForegroundColor Green
Try{
Update-Tools $VM -ErrorAction Stop -RunAsync
$vmobj = "" | Select VM, Status
$vmobj.VM = $VM.name
$vmobj.Status = "VMTools installed successfully"
$report += $vmobj
}
Catch{
$vmobj = "" | Select VM, Status
$vmobj.VM = $VM.name
$vmobj.Status = $_.Exception.Message
$report += $vmobj
}
}
$report | Export-csv C:\temp\VMTools-Upgrade-Status.csv -notypeinformation.
I found some workaround mentioned here https://serverfault.com/questions/654415/powercli-move-vm-returns-failure-but-vm-still-moves but not sure how to incorporate the same in my script or is there any other way to resolve it.
Please help.