I think I just discovered that something embarrassingly fundamental has eluded me about PowerCLI. Previously, I thought that an object representing a VM (for example) was at all times a hot window into the state right now of the VM, dynamically refreshed by the system when necessary. I never tested this; it was just my assumption. But I'm coming to the conclusion, based on experimentation, that it's a cold record of the VM's state at the time Get-VM was called. Am I right here?
On research, I found that if you do $myview = Get-View $vm.ID, you can call $myview.UpdateViewData() and then get fresh information. As far as I can tell, there's no "update" or "refresh" method for just plain ol' VM objects, correct? I would just need to repeat the Get-VM operation.
Thanks to anybody who can let me know whether I'm on the right track.
You're absolutely correct.
With the vSphere objects that you get through Get-View, there is the UpdateViewData method that refreshes the object's properties.
With the objects returned by the regular PowerCLI cmdlets, like Get-VM, there is no such functionality besides calling Get-VM again.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You're absolutely correct.
With the vSphere objects that you get through Get-View, there is the UpdateViewData method that refreshes the object's properties.
With the objects returned by the regular PowerCLI cmdlets, like Get-VM, there is no such functionality besides calling Get-VM again.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference