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

Re: Get VM IP and MAC

$
0
0

My console output, tested on one VM with two external nics and a internal 'dummy' interface

 

Name                               IP                                  MAC

----                                   --                                    ---

VM1                                192.168.1.1                     00:50:56:xx:xx:xx

VM1                                192.168.2.1                     00:50:56:xx:xx:xx

VM1                                192.x.x.xxx                     xx:xx:xx:xx:xx:xx

 

Do you see any of the expected addresses in the VM summary using vSphere Client?

 

 

Ah sorry, I forgot about the PS 3.0 requirement.

You could put every entry into an array and export the whole at the end of the script.

 

     $out= @()
     $VMs= Get-Datacenter $DC | get-vmhost | Get-VM
     foreach ($VMin$VMs) {
        
$VMx= Get-View $VM.ID
        
$HW=$VMx.guest.net
        
foreach ($devin$HW)
         {
            
foreach ($ipin$dev.ipaddress)
             {
                
$out+=$dev | select @{Name ="Name"; Expression = {$vm.name}}, @{Name ="IP"; Expression = {$ip}}, @{Name ="MAC"; Expression = {$dev.macaddress}}
             }
         }
     }

     $out | Export-Csv-NoTypeInformation-Path"VM-IP-Info.csv"

 

Regards

Emanuel


Viewing all articles
Browse latest Browse all 230663

Trending Articles



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