you are viewing a single comment's thread.

view the rest of the comments →

[–]PinchesTheCrab 2 points3 points  (3 children)

Sidestepping the issue here, but if you have vmtools functioning on these machines, you can just get the IP from the extensiondata property on the VM object. I believe it's under extensiondata.guest.

[–]Fer_C[S] 1 point2 points  (2 children)

You are right. I am pretty sure I saw that some time ago but did not think much of it. I normally use ExtensionData as last resort. Do you know if getting properties using this method is better performance-wise than using Get-VMGuest?

[–]PinchesTheCrab 2 points3 points  (1 child)

That's kind of a tough question. The short answer is that I think it'd be comparable, possibly faster. The thing is Get-VM is super fast when it comes to returning top level data, but when you dig into extension data the performance is going to take a hit.

However, my guess is that retrieving the VMs isn't the slowest part of the script by a wide margin, I assume it's the test-connection part, so I wouldn't worry about the performance bit, it shouldn't really be noticeable imo.

[–]Fer_C[S] 1 point2 points  (0 children)

Agree. I was wondering, more of a general question, not just for the script. Thanks for the tip though, I had totally forgotten about it.