VMware Cloud Community
orwinlopes
Contributor
Contributor

how to get IP Address from vm-ID

Hi All,

I want a query which i can use to run on vCenter Host to get the IP Address of the vm-ID. Can i get it since i want to add it in my automation workflow.

i think there should be some simple powerCLI command which i can use.

4 Replies
Buchti
Contributor
Contributor

Hi orwinlopes

This oneliner should do your work:)

Get-VM | Select Name,ID, @{Name="IP";Expression={@($_.Guest.IPAddress[0])}} | Where {$_.Id -Like "*113805"}

Just replace the "113805" with your ID but leave the asterisk.

If you need multiple IP-Addresses you can change the index of $_.Guest.IPAddress[0]


Tobi

orwinlopes
Contributor
Contributor

Hi Butchi,

Thanks for your prompt reply.Seems like a powershell query to me...my vCenter Host does not run on Windows..

Orwin

0 Kudos
Buchti
Contributor
Contributor

Hi Orwin

Sorry I didn't know you've got a vCenter Appliance. You wrote PowerCLI on the first Post so I assumed you got a vCenter running on Windows.

Buchti

0 Kudos
virtualkim
Enthusiast
Enthusiast

Orwin  PowerCLI is VMware's version of PowerShell. 

I can perfectly run PowerCLI (Shell) commands against my vCenter appliance in 5.5.

Kim

0 Kudos