Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 214415

Get VM IP and MAC

$
0
0

Hi

 

I'm trying to get the vm IP and MAC from one of my datacenters.

 

     When I run the following script two things happen:

 

1. I only see one vm in the csv file output.

2. When I send the output to the PowrCLI prompt I only see one mac and one IP for vm's that have to nics.

 

Script

---------

$VMs = Get-Datacenter $DC | get-vmhost | Get-VM

foreach ($VM in $VMs){

    $VMx = Get-View $VM.ID

     $HW = $VMx.guest.net

     foreach ($dev in $HW)

    {

        foreach ($ip in $dev.ipaddress)

        {

            $dev | select

            @{Name = "Name"; Expression = {$vm.name}},

            @{Name = "IP"; Expression = {$ip}},

            @{Name = "MAC"; Expression = {$dev.macaddress}}  |

            Export-CSV VM-IP-Info.csv -NoTypeInfo

           

 

        }

    }

}


Viewing all articles
Browse latest Browse all 214415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>