Adding vswitch and portgroup in a stat report information

Hi - I have a script that details stats for 24 hours. I'm trying to change so that it displays the name of vSwitch the VMNIC is attached to (IE vSwitch0 vSwitch1 etc).  I tried to get the information to display, but I either get a column empty, or I get all vswitches listed in each row.  Any advice?  Thanks in advance

$date = get-date

$vccred = import-pscredential-path xxxxxx

to connect-VIServer-Server xxxxxx-Credential $vccred

$metrics = "net.received.average", "net.transmitted.average".

$todayMidnight = get-Date-time-Minute 0 - 0 - 0 second

$start = $todayMidnight.AddDays(-1). AddSeconds (1)

$finish = $todayMidnight

foreach ($cluster Get-cluster | name tri-objet)

{

ConvertTo-Html-body"

$cluster

" | Out-file - add $htmlNICstats

$clusterTmp = @)
write-host ">" $cluster
foreach ($esxImpl in (get-vmhost-location $cluster |)) Sort-Object name))
{
write-host ">" $esxImpl

$ESXHostTMP = @)

$esx = $esxImpl | Get-View

{foreach ($vmhost to $esx)

$stats = get-Stat-entity $esximpl - Stat $metrics - start $start - finishing $finish

$stats | Group-object - property Instance. where {$_.} {Name - not ""} | %{

$row = "" | Select Date, NIC, vswitch and NOMCLUSTER, 'Max send Mbps', 'ESX Name","Max has received Mbps. "

$row.clustername = $cluster.name

$row.vswitch =

$row. "" ESX Name ' = $_. Group [0]. @entity.name

$row. Date = $start. ToShortDateString()

$row. NIC = $_. Group [0]. Instance

$row. "" MBps Max Send "=" {0: F2} "f (($_.)) Group | where {$_.} MetricId - eq "net.transmitted.average"} | Measure - Object - property - maximum value). Maximum / 1 KB)

$row. "" Max received Mbps "=""(($_.) f) Group | where {$_.} MetricId - eq "net.received.average"} | Measure - Object - property - maximum value). Maximum / 1 KB)

$ESXHostTMP += $row

$Report = $Report + $row

}

}

$ESXHostTMP | Nic Tri-objet | ConvertTo-Html-property NOMCLUSTER, vswitch, "ESX Name", Date, NIC, "Max send Mbps", "Max received Mbps | Out-file - add $htmlNICStats

}

The script looks only at the active network cards.

$pg = $vmhost.Config.Network.Portgroup |where {$_.ComputedPolicy.NicTeaming.NicOrder.ActiveNic -contains $group.group[0].Instance} | %{$_.Spec.Name}

If you want to include network standby cards as well, this line should be

$pg = $vmhost.Config.Network.Portgroup |where {$_.ComputedPolicy.NicTeaming.NicOrder.ActiveNic -contains $group.group[0].Instance -or $_.ComputedPolicy.NicTeaming.NicOrder.standbyNic -contains $group.group[0].Instance} | %{$_.Spec.Name}

Let me know if it gives the results you expect.

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • VLANS can be configured at the vSwitch and Portgroup level?

    Dear friends,

    I hope that all do you good...

    Two statements are true about groups of ports and VLAN defined on a switch vNetwork Standard? (Choose two)

    A. A VLAN can be configured for the entire virtual switch or on groups of individual ports

    B. several groups of ports can specify the same VLAN

    C. VLAN can only be configured on individual port groups

    D. several VLANS can be specified in a port group

    VLANS can be configured at the vSwitch and Portgroup level?

    B. several groups of ports can specify the same VLAN

    C. VLAN can only be configured on individual port groups

  • vSwitch and Portgroup security settings

    I'm looking for a way to query the security settings ("Promiscuous" Mode, forged passes and changes of MAC) the vSwitches and exchanges. MY PS skills are limited. I can get about this until now especially of patching together various scripts that I found. However at this point, I provide a vSwitch and even when I am able to get this information I don't know what to do after that.

    {Foreach ($VMHost in Get-VMHost)

    Foreach ($vSwitch to ($VMHost |)) Get - VirtualSwitch)) {}

    $hostMoRef = get-VMHost $VMhost | % {Get-view $_.} ID}

    $hostNetwork = $hostMoRef.configManager.networkSystem

    $hostNetworkMoRef = get-views $hostNetwork

    $hostNetworkMoRef.NetworkInfo

    }

    }

    PowerCLI 4.1, you can use the property, Extensiondata get to the managed object.

    To display the list of all your vSwitches and their exchanges, security settings, you can do something like this

    foreach ($VMHost in Get-VMHost){
         foreach($vSwitch in $VMHost.ExtensionData.Config.Network.Vswitch){
              Write-Host $vSwitch.Name
              Write-Host "`tPromiscuous mode:" $vSwitch.Spec.Policy.Security.AllowPromiscuous
              Write-Host "`tForged transmits:" $vSwitch.Spec.Policy.Security.ForgedTransmits
              Write-Host "`tMAC Changes:" $vSwitch.Spec.Policy.Security.MacChanges
              foreach($portgroup in ($VMHost.ExtensionData.Config.Network.Portgroup | where {$_.Vswitch -eq $vSwitch.Key})){
                   Write-Host "`n`t" $portgroup.Spec.Name
                   Write-Host "`t`tPromiscuous mode:" $portgroup.Spec.Policy.Security.AllowPromiscuous
                   Write-Host "`t`tForged transmits:" $portgroup.Spec.Policy.Security.ForgedTransmits
                   Write-Host "`t`tMAC Changes:" $portgroup.Spec.Policy.Security.MacChanges
              }
         }
    }
    

    Note that the a security framework for a portgroup will be empty (= not) when he uses the corresponding inherited vSwitch parameter.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • How to see the VSwitch and PortGroup properties in the managed object browser

    Hello

    We have a laboratory infrastructure VI3, with a VC and some ESX servers running.

    In the managed object browser, I'd like to see the properties of certain objects,

    especially the VSwitches and exchanges.

    How do I see VSwitch and exchanges from the CROWD. Here's my data:

    ESX IP address: 192.188.0.228

    VSwitch name: vSwitch0

    The port group name: VM_PG

    I know that we can see these properties of Client VI, but I really want to see values

    returned for each of the attributes defined in the WSDL file and the CROWD precisely

    allows me to do. This will help me to do a bit on our end of modeling.

    I tried, but I couldn't really vSwitch. Grateful if someone can give inputs.

    Thank you

    Try this:

    https://A.B.C.D/mob/?moid=ha-host&doPath=config.network
    

    and more precisely which lists out them the portgroup and vSwitches

    https://A.B.C.D/mob/?moid=ha-host&doPath=config.network
    

    =========================================================================

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    http://Twitter.com/lamw

  • Why do I need "Promiscuous" Mode when you use multiple vSwitches and a bridge?

    Hello guys,.

    5.5 ESXi running.

    I created two vSwitches and putting multiple virtual machines in each vSwitch. I have a CentOS VM with two network cards, one in each vSwitch. I configured the CentOS VM to work as a bridge. I could spend between devices on a vSwitch pings, but ping has no devices on a vSwitch devices on the other (through the CentOS acting as a bridge). The ARP requests have been sent across the bridge, but have never had sent answers ARP. I checked around online and someone recommended to enable Promiscuous Mode. I activated the Promiscuous Mode (changing to refuse to accept) on the two vSwitches (which is then applied to the change to all virtual machines). You can read more about that here: VMware KB: how "Promiscuous" mode operates on the virtual level switch and portgroup

    Now all of a sudden, everything works.

    My question is: why?

    I think that I don't want to Promiscuous Mode unless it must be such that it will result in more traffic to each VM it had reached before. I don't really understand why I need to authorize this change, and any help would be nice!

    Without promiscuous mode, vSwitch and port group will only transmit traffic VMs (MAC addresses) that are directly related to the port groups, he will not learn the MAC addresses that, in your case, are the other side of the bridge. The "Promiscuous" mode, all traffic is sent to each virtual machine on the vSwitch and port group and it's virtual machine to decide what to do with the network packets. As you have already mentioned, this isn't a parameter that you want to apply to a large number of virtual machines. For this reason, you can create a second group of ports on the vSwitch with only of CentOS virtual machine and activate the "Promiscuous" mode on only this group port rather than the vSwitch.

    André

  • Is it possible to get clip names and additional descriptions (and other metadata) in a report? The number, .xls or some other document available?

    I have about 12 tablespoons of images recorded on several projects. Each clip has a description added to it. I'm trying to find a way to search for a specific content easier. Since so much information was laboriously on slot form of description of metadata, it would be great to be able to use it. Which brings me to the question -

    Is it possible to get clip names and additional descriptions (and other metadata) in a report? The number, .xls or some other document available?

    Thank you!

    Karim.

    one way is to highlight all the media/bins in the project Panel and from the menu, export the batch list. This will create a .csv text file.

    There is also this option in another post, but do not know how it works. First Pro CC - how can I export metadata custom in Excel?

  • Added "ublock" and redirect cleaner"now I can't connect to my MLB account com on the main page.

    I can't access my MLB.com account. When I click on the connection icon, nothing happens. I've had this account for years and it has worked before. I recently added UBlock and Redirect cleaner. Is there a way to identify the cause and correct it?

    Hello

    I assume from what you say that one of the two Add-ons blocks perhaps inadvertently MLB.com to open.

    I would recommend that you take a look at the parameters of both of these modules and set the page of MLB.com , want to get on an exceptional basis to allow him to cross.

    I hope this helps, but if not, please come back here and we can look at another solution for you.

  • I added Wikipedia and Wikivoyage to my search engine and the icons are not there. How can I add them?

    In the search in the top right of my browser, I recently added Wikipedia and Wikivoyage as options, but the icons are not there. Instead, I have a blank white page instead of the icons. How can I fill them in?

    This also happens on my laptop which is a Macbook Air, so it's not limited to the Windows 7 version of Firefox.

    When there is no data icon in the XML file, then Firefox will be able to display such an icon.

    Try adding on Mycroft Project website search engines.

  • In the middle of my teens adding devices, and registration for the apple's music, security issues have been changed and now nobody seems to remember the answers.  How can you bypass those to change your settings?

    In the middle of my teens adding devices, and registration for the apple's music, security issues have been changed and now nobody seems to remember the answers.  How can you bypass those to change your settings?

    You must ask security team account Apple to reset your security questions. To contact them, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.


    (140233)

  • Toshiba value added logical and device for general use - what is it?

    Hello

    I completely put in place a new system on the Tecra S2, Win XP and everything. All the drivers from the site Web of Toshiba helped but now only a single 'questionmark' remains in the hardware Manager:

    Toshiba added value to general use and logical device

    I cannot find a driver anywhere or so for that. What is it indeed?
    The laptop works fine, no problem.

    Greetings,
    Ben

    I think it is (among other things) an ACPI driver...
    and you can download it-I remember...
    don't forget the 'value added package' and 'common modules' to install

  • I have a bank I have to use Google's browser instead of safari to be able to download and view my monthly statement.  Auto-complete in safari on id and psd won't AutoFill to this browser.  What can we do to make it right?

    I have a bank I have to use Google's browser instead of safari to be able to download and view my monthly statement.  Auto-complete in safari on id and psd won't AutoFill to this browser.  What can we do to make this right?

    I have safari 9.0.2 have a MacBook Pro.  OS X El Capitan version 10.11.2 for operating system

    If they are having problems with the Safari browser, you must contact the Bank to know if their site is compatible with Safari.

    Good day.

  • computer crashed, used the backup to restore, formated instead and charged in the State of origin. any chance to recover photos lost at this stage?

    computer crashed, used the backup to restore, formated instead and charged to the State of origin, no chance to recover lost photos at this stage?

    Hello

    It is a good free program to recover data. but no guarantee.

    http://www.Piriform.com/Recuva

    You may need to contact the data recovery specialists, who are very expensive.

    See you soon.

    p.s., You use your computer, the less chance you have of data recovery.

  • Why my ink on my printer and my computer ink level report do not match?

    Why my ink on my printer and my computer ink level report do not match?

    ink level?

    Hello

    You should check their documentation online with the help of the manufacturer of the printer, and
    drivers and ask in their forums (if any). The OEM printer manufacturer is responsible for
    the functioning of the printer and their supplied drivers and other software.

    It is not a Windows problem.

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • All my adobe files are corrupt. I saved them on my computer, my external hard drive and flash players. All report them at the same time as all my PSD files and I are corrupt.

    All my adobe files are corrupt. I saved them on my computer, my external hard drive and flash players. All report them at the same time as all my PSD files and I are corrupt.

    My computer recently had an error with the System 32 and will not open if I reformat, which means I lose everything on it. No problem, because I supported straight? It turns out that all my backups say they are corrupt. Do I just terrible luck, or is there a reason why none of my files works when I try to open them on another computer?

    Try the bugcheck on the ext hdd. Right click on the drive in 'my computer' > 'properties' > 'Tools' > click 'check now '.

    You can restart your pc and reconnect the ext hdd.

    Recuva Piriform is a free data recovery program.

    Google for more solutions

  • Handling VSwitch and network

    Hi, I have have a question: How fact un Working VSwitch , If two virtual machines to communicate between them. If the data on the network is sent to the NIC and then the material or communication is managed in the VSwitch?


    Greetings from the Germany!


    Michael Burkhardt


    If virtual machines are on the same vSwitch and VLAN traffic is not struck the physical network adapter.  If virtual machines have been on different vSwitches, traffic would hit the physical network.  Even if the virtual machines are on different VLAN traffic would pass through your router.

Maybe you are looking for