getvSwitchMacTable.pl

Version 3

    This script allows you to dump information about your vSwitche(s) pertaining to the VM(s) that are attached, the portgroups in which the VM(s) are attached to and the corresponding MAC Address that maps to the portgroup/vswitch

     

    You can specify a specific Cluster, Datacenter or if execute against vCenter without options, it will extract ALL VMs or you execute against an individual ESX(i).

     

     

    UPDATE:

    Script has been updated to support distributed vSwitches along with cleaner output

     

     

    Requirements:

    vCenter 2.5 or vCenter 4.0

    ESX(i) 3.5 or 4.0

    vMA 4.0 or vSphere SDK for Perl 4.0

     

    Download Script here

     

    Sample Execution:

     

    Specify specific Datacenter:

    [vi-admin@scofield ~]$ ./getvSwitchMacTable.pl --server reflex.primp-industries.com --datacenter "Primp-R&D"
    VM NAME                                      MAC ADDRESS               PORTGROUP                       VSWITCH
    -------------------------------------------------------------------------------------------------------------------------------
    
    Datacenter: Primp-R&D
    
    vm-1                                         00:50:56:92:32:9c         VM Network                      vSwitch0
    -------------------------------------------------------------------------------------------------------------------------------
    vm-2                                         00:50:56:92:49:25         VM Network                      vSwitch0
    -------------------------------------------------------------------------------------------------------------------------------
    vm-2                                         00:50:56:92:32:a7         VM Network                      vSwitch0
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:63:61         VM Network                      vSwitch0
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:00:e4         VM Network                      vSwitch0
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:09:13         VM Network                      vSwitch0
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:3c:71         VM Network                      vSwitch0
    -------------------------------------------------------------------------------------------------------------------------------
    vm-3                                         00:50:56:92:02:d8         Internal                        vSwitch1
    -------------------------------------------------------------------------------------------------------------------------------
    vm-3                                         00:50:56:92:17:2f         Internal                        vSwitch1
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:63:61         Internal                        vSwitch1
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:00:e4         Internal                        vSwitch1
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:09:13         Internal                        vSwitch1
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:3c:71         Internal                        vSwitch1
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:63:61         Production                      vSwitch3
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:00:e4         Production                      vSwitch3
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:09:13         Production                      vSwitch3
    -------------------------------------------------------------------------------------------------------------------------------
    vm-4                                         00:50:56:92:3c:71         Production                      vSwitch3
    -------------------------------------------------------------------------------------------------------------------------------
    
    

     

    Specify specific Cluster:

    [vi-admin@scofield ~]$ ./getvSwitchMacTable.pl --server reflex.primp-industries.com --cluster "R&D"
    

     

     

    Specify specific Host:

    [vi-admin@scofield ~]$ ./getvSwitchMacTable.pl --server esxi35u4.primp-industries.com
    

     

     

    All:

    [vi-admin@scofield ~]$ ./getvSwitchMacTable.pl --server reflex.primp-industries.com