VMware Cloud Community
aviv12
Contributor
Contributor

script to find static ip address

hi

i am new in VMware powerCLI scripting , i am looking for script that find all VM's that running with Static IP addess.

is it possible ?

thanks

0 Kudos
3 Replies
LucD
Leadership
Leadership

Have a look at  1.  Re: Getting guest IP address

Or did you mean, guests that are configured to have a static IP vs a DHCP assigned IP ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
aviv12
Contributor
Contributor

thanks you for your quick reply.  Yes i meant to guests that are configured as static IP vs a DHCP assigned IP .

0 Kudos
LucD
Leadership
Leadership

From PowerShell v4 onwards you can do the following

Get-NetAdapter |

Select Name,

    InterfaceIndex,

    @{N='DHCP';E={Get-NetIPInterface -InterfaceIndex $_.InterfaceIndex | Select -ExpandProperty DHCP}}

Note that this needs to run inside the guest OS (via Invoke-VMScript or with a remote PowerShell session)

If you're not on PowerShell v4 yet, you can achieve the same via the WMI classes.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos