PowerShell: XenServer Get VM IP Address
This like all of these PowerShell XenServer examples requires you load the snapin and an active connection to a XenServer.
First you need to get a reference to your VM of choice, in this case I know the exact VM by name so I do this:
$vms = Get-XenServer:VM | Where-Object {$_.name_label -eq "<nameofVM>"}
Now I want to read the guest metrics on this VM to find the IP Address, note that this requires XSTools to be installed and the IP address wont be available right away, typically it seems to only be available after the machine has both booted, and had time for the XSTools to report it's IP to guest metrics, but once it's available you can get it by doing this:
Get-XenServer:VM_guest_metrics.Networks -VMGuestMetrics $vms.guest_metrics
Be aware that if you want to get a list of IP's for more than one VM you will need to foreach through $vms and run the command for each one.
One potential use of this is to, say, clone a new VM from a template, start it, wait for it to establish a network connection then Test-Connection until you get a result, at which time you can proceed to do whatever else you need to do (via WinRM for instance, if you have it enabled in the template).