Need a powershell script to extract VM-> IP->->-> mapping vSwitch portgroup vNIC

Hello

I need a powershell script to extract the following information for all the VMS in vcenter.

vm_name | ESX_name | Cluster_name | vm_IP_address | vNIC_name | PortGroup | vSwitch

Please note that multiple virtual machines have several vNIC where vNIC is connected to various exchanges

Here you go

$report = @()
Get-VM | %{
     $vm = $_
     $_ | Get-Vmguest | %{
          $guest = $_
          if($_.Nics){
               $i = 0
               $_.Nics | %{
                    $row = "" | Select Name, Powerstate, Host, Cluster, "IP address","Nic Name",Portgroup,vSwitch
                    $row.Name = $vm.Name
                    $row.Powerstate = $vm.PowerState
                    $row.Host = $vm.Host.Name
                    $row.Cluster = ($vm.Host | Get-Cluster).Name
                    $row."IP address" = $guest.IPAddress[$i]
                    $row."NIC Name" = $vm.NetworkAdapters[$i].Name
                    $row.Portgroup = $guest.Nics[$i].NetworkName
                    $row.vSwitch = (Get-VirtualPortGroup -Name $guest.Nics[$i].NetworkName -VM $vm).VirtualSwitchName
                    $report += $row
                    $i++
               }
          }
          else{
               $row = "" | Select Name, Host, Cluster, "IP addr","Nic Name",Portgroup,vSwitch
               $row.Name = $vm.Name
               $row.Powerstate = $vm.PowerState
               $row.Host = $vm.Host
               $row.Cluster = ($vm.Host | Get-Cluster).Name
               $row."IP address" = "na"
               $row."NIC Name" = "na"
               $row.Portgroup = "na"
               $row.vSwitch = "na"
               $report += $row

          }
     }
}
$report

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • Need a PowerShell script to...

    Hi, I need a PowerShell script to list all the virtual machine from the center of data-list for each virtual computer all drives and formats the disc and the disc type and a free column for comments.

    Move us the backup platforms and try to develop a plan of migration for all virtual machines

    See you soon

    Looks like you are using an older version of PowerCLI, the CapacityGB was introduced in one of the previous PowerCLI builds.

    Try to upgrade.

    If an upgrade is not possible, you can do

    Get-Datacenter -Name MyDC | Get-VM | Sort-Object -Property Name |Get-HardDisk | Select @{N="VM";E={$_.Parent.Name}},Name,@{N="CapacityGB";E={[int]($_.CapacityKB/1MB)}},@{N="Type";E={[string]::Join('/',($_.DiskType,$_.StorageFormat,$_.Persistence))}},@{N="Comment";E={' '*25}} |Export-Csv C:\HD-report.csv -NoTypeInformation -UseCulture
    

    It also sorts the VM on their Name property.

  • Need a powershell script to create a local user on esx given the esx server list box

    Hello

    I need a powershell script to create a local user on esx in a given list entry of esx servers through a csv spreadsheet. The script should ask me the user name and the password for the user name to be created on the given list of esx servers.

    Thanks in advance!

    Just noticed that there is a lack of vacuum after the - password parameter.

    It should be

    $userName = Read-Host "Username"
    $password = Read-Host "Password" -AsSecureString:$true
    Import-Csv "C:\vmhosts.csv" | %{
         Connect-VIServer -Server $_.Hostname -Credential (Get-Credential)
         New-VMHostAccount  -Id $userName -Password $password -UserAccount:$true -GrantShellAccess:$true -Confirm:$false
         Disconnect-VIServer -Confirm:$false
    }
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Need a powershell script to find the PID of VM in an ESX box

    Hello

    I need a powershell script to list out the PID of all virtual machines running in a box of ESX.

    The script should prompt for ESX box name and root password.

    Expected results:

    The virtual computer name.  NEST

    Thanks in advance!

    My mistake, the point (any character) is to eat the rest of the message.

    Try again with

    $mask = [regex]"vmid=(\d+)\s+([\w-]+)"
    

    He accepts what regex esteem alphabetic characters or the hyphen (-).

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Need a powershell script to gather information from ESX host

    Hello

    I need a powershell script to collect the below given information host ESX to the Virtual Center. My VC:2.5 of the environment, the ESX hosts: 2.5, 3, 3.5

    At present I have individual powershell scripts of a steamer to get these details. Would be more useful to have a single script. I tried VESI, but does not receive the report in the below in the format.

    | ESX host name Version | Number | construction | manufacturer Model | Processor type | Number of physical CPUS | Number of cores | VMotion service IP Console IP | | County HBA | Physical NETWORK interface cards count

    Thanks in advance!

    So I'm at my wits end here.

    It works for me and Robert also confirmed that it worked for him.

    Although I don't see why this would solve the problem, you could finally try an upgrade to PowerShell v2 RTM.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Need to powershell script to gather the host ESX Info network

    Hello

    I need two scripts powershell to collect two types of information about the ESX host network.

    1. information vNIC -& gt; information on the vmnic (physical ESX host network adapter) connected to vSwitches.

    vNIC | VSwitch model | | Trade | Speed | Status | | PCI slot Active/stand-by/not assigned

    (Example) output expected:

    vmnic0 | intel corporation 82XXXX gigabit ethernet controller | vSwitch0 | service console, vMotion | 1000mbps Full | up 01:01.00 | | Assets

    2. Portgroup information

    PortGroup | vNIC (s) with active / standby |  PCI slot of vNIC (s) with active / standby | Physical switch with port number

    Expected results (example):

    Service console | vmnic0 (a) : (s) | 01 vmnic1: 00. 00 (a) : 02:00. 00 (s) | abcd-123 [GigabitEthernet10/10] : xyzf-7890 [Gigabitethernet11/11]

    Please note if CDP is not active, then in the field of physical switch values can contain "CDP is not enabled"

    Thanks in advance!

    Noticed that the two threads under became a little mixed in the script.

    This is the script with the devIds with the indication of the active / standby.

    foreach($esxImpl in (Get-VMHost)){
         $esx = $esxImpl | Get-View
         $netSys = Get-View $esx.ConfigManager.NetworkSystem
         foreach($pg in $esx.Config.Network.Portgroup){
              $pNICStr = @()
              $pciStr = @()
              $cdpStr = @()
              foreach($a in $pg.ComputedPolicy.NicTeaming.NicOrder.ActiveNic){
                   if($a){
                        $pNICStr += ($a + "(a)")
                        $pciStr += ($esx.Config.Network.Pnic | where {$_.Device -eq $a} | %{$_.Pci + "(a)"})
                        $cdpInfo = $netSys.QueryNetworkHint($a)
                        $cdpStr += &{if($cdpInfo[0].connectedSwitchPort){$cdpInfo[0].connectedSwitchPort.devId + "(a)"}else{"CDP not configured(a)"}}
                   }
              }
              foreach($s in $pg.ComputedPolicy.NicTeaming.NicOrder.StandbyNic){
                   if($s){
                        $pNICStr += ($s + "(s)")
                        $pciStr += ($esx.Config.Network.Pnic | where {$_.Device -eq $s} | %{$_.Pci + "(s)"})
                        $cdpInfo = $netSys.QueryNetworkHint($s)
                        $cdpStr += &{if($cdpInfo[0].connectedSwitchPort){$cdpInfo[0].connectedSwitchPort.devId + "(s)"}else{"CDP not configured(s)"}}
                   }
              }
    
              $pg | Select @{N="ESXname";E={$esxImpl.Name}},
              @{N="Portgroup";E={$pg.Spec.Name}},
              @{N="VLANid";E={$pg.Spec.VlanId}},
              @{N="pNIC";E={$pNICStr}},
              @{N="PCI location";E={$pciStr}},
              @{N="Physical switch";E={$cdpStr}}
         }
    }
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Need a powershell script to collect info patch esx

    Hello

    IAM looking for a powershell script that collects the result of "motion esxupdate" for all versions of esx host 3.5 in the Virtual center 2.5 version and exports to CSV file.

    It should take input as virtual Center and collect all the information of ESX host, connect to esx hosts, run the esxupdate query and update of the CSV with results.

    I got the code base of other scripts. I've pasted below. He collects only results for esx server in view of the need to modify the code for the above requirements.

    -


    $servers = "server0″", server1″

    $account = "root".

    $password = "password".

    $servers | % {$a = plink - pw $password $account@$_ "esxupdate query"

    {$server = $_}

    -


    Thanks in advance!

    Have you tried running the script in the powershell console?

    May be a problem with the vesi script editor.

    Sent from my iPhone

    On 19 March 2010, at 21:14, Sureshadmin<>

  • Need a PowerShell Script to list all my stores of data, capacity and VMFS format.

    All,

    I need a script to list all my stores of data, capacity and VMFS format.

    That's what I have so far but its does not give me the results I need.

    Get-Datastore - Datacenter MN_PROD | where {$_.} Type - eq "VMFS"} | Select-Object Name,@{N="VMFS version. {E = {$_.Info.Vmfs.Version}}

    Try like this

    Get-Datastore -Datacenter MN_PROD | where {$_.Type -eq "VMFS"} | Select-Object Name,CapacityGB,    @{N="VMFS version";E={$_.FileSystemVersion}}
    
  • do I need Windows PowerShell integrated scripting tool for home computer and access to the internet, powershell

    do I need Windows PowerShell integrated scripting tool for computer and internet access

    No you didn't he need for home computer and internet access

  • I need an example script Powershell in Windows 7

    I can repeat this request I presented during my "subscription", but he doesn't know if it took.

    I would be recognizing an example of a Windows Powershell Script that looks up a record in a file and displays the content of this record on my screen. Records are scanned from Documents. They are scanned by user 'XX' within the Date.

    The path is: C:\Documents\DailyPosting

    I've programmed in a distant past, but did not use scripts. If I had an example I could go from there. I don't read very well of manuals.

    I am 78 years old. Would be grateful yourhelp!

    Thank you

    Cmawsquaw

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the link below.

    http://social.technet.Microsoft.com/forums/en/category/scripting

    Hope this information helps.

  • Such a powershell script exist?

    Windows Server Standard 2012R2. I know not enough about powershell scripts to be dangerous. So I guess that its better to ask for help on this one. As you know, in the Windows backup program, the e-mail feature is depreciated on server 2012. However, I had no problem of customization of a powershell script that I found so that it sends an email when the nightly backup is completed successfully. Te was easy to do. In Manager tasks I just put the firing an event, with the event being backup Windows and a number of event 4 - which means backup completed successfully. In fact, it works very well for my clients.  But it is not the fault of my client. (of course!)

    Customers only the desire to receive an email if the backup is not successful. But the reasons for a backup failed are many which can generate any number of errors in the event log. Since I'm just not knowledgeable of powershell scripts, I hope someone can help me here, or at least direct me to where I can get help. Basically, I need a script powershell like this:

    Trigger is "the eventID 14 (completed backup operation).

    If eventID in the Microsoft-Windows-backup/OPerational log prior to the triggering event is not 4, while sendmail

    This above would of course, include my work already sendmail script. Is this possible? Maybe someone has already done? Any help would be appreciated.

    Hello

    For technical support, repost the question in the Windows Server Forum.

    https://social.technet.Microsoft.com/forums/WindowsServer/en-us/home

  • Reference Dell EqualLogic Powershell Script &amp; replicas

    Hi all

    I develop a script to extract information on replicas made between two bays EQL PS Series Dell.

    For each volume, I keep a history of 10 aftershocks, I use the following command to display all the replicas made of a specific volume.

    > get-eqlreplica - GroupName SANPROD - ReplicationSite SANBCK - VOLUME VolumeName

    But I'm unable to get the size for each replica. Is it possible to do this with the cmdlet provided by Dell?

    Thanks for your help!

    Currently the cmd - allows PowerShell does not size of replication data.  For now, only the GUI and the SANHQ can show you the size of each replication.

    -joe

  • PowerShell script

    Hello

    Say I want to install the Microsoft Patches each month on a field with 50 + servers. I need a script that could give me the following,

    (i.) the availability of each server present in the field, while running the script.

    II.) he should list on the fixes that have been set up so far and this should be exported to excel.

    Servers are 2003 & 2008. Also, I'm not particularly on Powershell scripts. So anything that meets the objective would be really useful.

    Please help me with this.

    Thank you much in advance.

    René-coral. (* E-mail address is removed from the privacy *)

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.technet.Microsoft.com/forums/en-us/home

    http://social.msdn.Microsoft.com/forums/en-us/home

  • Newbie question - tide may run a remote PowerShell script or BAT file?

    My first post.  I am new to raz, but I've had experience with other planners.

    I have a PowerShell script that must be run on a remote computer.  All the script needs software is installed on this computer.

    In addition, I need the script runs under a service account.  Is it possible and if yes, how can I go about it?

    This work will be be launched manually whenever this is necessary.

    Sure. There are some screenshots. A variable one, I used for the location of the folder on the server of tide (not required but I use a lot of scripts). One for the command of tide itself. The last one is the script runs remotely on windows work. Let me know if they don't make sense.

  • Run the powershell script in Workflow VCO

    Hi guys,.

    I'm pretty new to VCO and I am facing difficulties to get what I want. For you, this will be a Basic... but here's my question:

    I have a WF that I use in the WFStubmachineprovisionning that can generate me a name of virtual machine based on the selection of the user while he asked for a virtual computer in the VRA.

    The VM provisionned name looks like this: W203PKLXXX and I need to replace the XXX with a number that is available on the network.

    To do this, I need to query the DNS to see if there is, if not, 002 001... And so on... until an available and I send the full name of the virtual machine to the WF Stubprovisionning.

    This my first try to interact between VCO and a Powershell script. I can run script PS on my host configured, but do not know how to send variables to the custom WF that generates the name of the script of PS and send the name of VM from the script of the PS to the next step.

    Can someone give me a sample of variable to manage? I can't find anything on the net

    Just to tell you that I managed.

    the PS has returned an XML object, not a string. I had to use the method getxml() javascript property, and parse the string to get the value I need

    I also had to blind correctly (getxml) entry and exit (PS)

    If needed I can send you a few screenshoot

Maybe you are looking for