Hello,
i want to Update the VMware Tools and become the vCenter Task Result back if it was Canceled, Error, or Successfully.
I have tried the Following, but i ever become back:
Get-View : Cannot validate argument on parameter 'Id'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
$task = Get-View -Id (Update-Tools -VM $Vm).Id
Write-Verbose "Wait up to $timeoutSeconds seconds until Update VMWare Tools task is finished..."
while ((New-TimeSpan -Start $startDate -End (Get-Date)).TotalSeconds -lt $timeoutSeconds -and ($task.Info.State -eq [VMware.Vim.TaskInfoState]::running -or $task.Info.State -eq [VMware.Vim.TaskInfoState]::queued)) {
Start-Sleep 10
$task.UpdateViewData()
}
if ($task.Info.State -eq [VMware.Vim.TaskInfoState]::running) {
Write-Verbose "Canceling Update VMWare Tools task after $timeoutSeconds seconds."
$task.CancelTask()
}
elseif ($task.Info.State -eq [VMware.Vim.TaskInfoState]::error) {
Write-Error "ERROR: Could not Update VMWare Tools for VM $VmName. :-("
}
You didn't use the RunAsync switch.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You didn't use the RunAsync switch.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thx a lot, i missed here Something 😉
The Id Error dont exists anymore.
The Tools are Updated, but i become back:
ERROR: Could not Update VMWare Tools for VM tools-update. 😞
Thats the Output from:
elseif ($task.Info.State -eq [VMware.Vim.TaskInfoState]::error) {
Write-Error "ERROR: Could not Update VMWare Tools for VM $VmName. :-("
But the Task for the Update Tools was successfully...
Did you check what actually is in $task.Info after the UpdateViewData call?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In the $task.Info.State says error.
In the vCenter the Task says: Cannot complete operation because VMware Tools is not running in this virtual machine.
But the VMware Tools are now updated on the VM.
I wanted to see what is in $task.Info, not $task.Info.State only.
But this is something that has been around for quite a while.
No clear, single explanation for this behaviour afaik.
You might want to check if there is anything in the logs (see KB1007873 for location).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference