Script to get the VLan ID, vSwitch, networking and group of vCenter vmkernel ports.

Hello

Need help to get the script of ' Script for the VLan ID, vSwitch, networking and group ports vmkernel of vCenter. "to CSV

Any help will be much appreciated.

Get-VMHost | {foreach}

$vmhost = $_

$PortGroups = $vmhost | Get-VirtualPortGroup

$vSwitchs = $vmhost | Get-VirtualSwitch

$pNic = $vmhost | Get-VMHostNetworkAdapter

$Managementinfo = $pNic | Where-Object {$_.} ManagementTrafficEnabled - eq $true}

$vMotioninfo = $pNic | Where-Object {$_.} VMotionEnabled - eq $true}

$FTinfo = $pNic | Where-Object {$_.} FaultToleranceLoggingEnabled - eq $true}

$vlanID = $PortGroup | Where-Object {$_.name - eq $Managementinfo.ExtensionData.spec.Portgroup} | Select-object - ExpandProperty VLanId

{foreach ($PG in $PortGroups)

#Management Info network

If ($Managementinfo.PortGroupName - eq $PG.) {Name)

$MGMTStatus = "enabled".

$ManagementIP = $Managementinfo | Where-Object {$_.} PortGroupName - eq $PG. Name} | Select-Object - ExpandProperty IP

}

else {}

$MGMTStatus = "Disabled".

$ManagementIP = $null

}

#vMotion Info network

If ($vMotioninfo.PortGroupName - eq $PG.) {Name)

$vmotionStatus = "enabled".

$vMotionIP = $vMotioninfo | Where-Object {$_.} PortGroupName - eq $PG. Name} | Select-Object - ExpandProperty IP

}

else {}

$vmotionStatus = "Disabled".

$vMotionIP = $null

}

#FT Info network

If ($FaultToleranceLoggingEnabled.PortGroupName - eq $PG.) {Name)

$FTStatus = "enabled".

$ftIP = $FTinfo | Where-Object {$_.} PortGroupName - eq $PG. Name} | Select-Object - ExpandProperty IP

}

else {}

$FTStatus = "Disabled".

$ftIP = $null

}

#vmKernel name

$VMKernel = $pNic | Where-Object {$_.} PortGroupName - eq $PG. Name} | Select-Object - ExpandProperty DeviceName

$result = "" | Select-Object HostName, vSwitchName, PortGroupName, VLanID, ManagementTraffic, ManagementIP, vMotionTraffic, vMotionIP, FTTraffic, FTIP, VMKernel

$result. Host name = $vmhost.name

$result.vSwitchName = $PG. VirtualSwitchName

$result. PortGroupName = $PG. Name

$result. VLanID = $PG. VLanID

$result. VLanID = $PG. VLanID

$result. ManagementTraffic = $MGMTStatus

$result. ManagementIP = $ManagementIP

$result.vMotionTraffic = $vmotionStatus

$result.vMotionIP = $vMotionIP

$result. FTTraffic = $FTStatus

$result. FTIP = $ftIP

$result. VMKernel = $VMKernel

$result

}

} | Export-Csv c:\temp\data.csv

Tags: VMware

Similar Questions

  • script to get the csv vm disk usage and export to csv format

    Hi all

    I am trying to create a script to get the use of disk for vm - space - free space and total disk space.

    I used this script that allows me to get the required result.

    but I need to edit the script for each cluster, VM he should get computers virtual cluster and check the vm disuage. and export of csv file

    $vms = import-CSV "C:\Cluster.csv".

    $outputfile = "c:\Diskusage.csv".

    SE connect-viserver VC-vcadmin username-password

    {foreach ($vm to $vms)

    Get - VM $vm.name | Where {$_.} PowerState - eq "Receptor"} | Get-VMGuest | Select the ExpandProperty - VMName disks | Select VMName, path, @{Name = "DiskCapacityGB"; Expression = {[math]: Round ((($_.))} {{((Ability) / 1 GB), 2)}}, @{Name = "DiskUsedMB"; Expression = {[math]: Round ((($_.))} Capacity - $_. {{((FreeSpace) / 1 MB), 2)}}, @{Name = "DiskFreeMB"; Expression = {[math]: Round ((($_.))} {{((FreeSpace) / 1 MB), 2)}} | Export-Csv - NoTypeInformation $outputfile}

    Viserver disconnect

    Joint the output file

    Veuileez help me in creating the script

    You can try like this?

    Connect-viserver VC -user vcadmin -password
    foreach($cluster in Get-CLuster){
        $outputfile = "c:\" + $cluster.Name + "-Diskusage.csv"    Get-VM -Location $cluster |
        Where { $_.PowerState -eq "PoweredOn" } |
        Get-VMGuest |
        Select VMName -ExpandProperty Disks |
        Select VMName, Path,
            @{Name="DiskCapacityGB";Expression={[math]::Round((($_.Capacity)/1GB),2)}},
            @{Name="DiskUsedMB";Expression={[math]::Round((($_.Capacity - $_.FreeSpace)/1MB),2)}},
            @{Name="DiskFreeMB";Expression={[math]::Round((($_.FreeSpace)/1MB),2)}} |
        Export-Csv -NoTypeInformation $outputfile}
    
    Disconnect-viserver
    

    The script creates a CSV file for each cluster.

  • Unable to get the database searched with MAX and GROUP BY function

    Hello
    All the

    I have a table as below:
    COLUMN TYPE
    User_id VARCHAR2 (10 byte)
    ID_processus VARCHAR2 (30 bytes)
    END_TIME DATE (STAMP)
    TO_LOC VARCHAR2 (12 bytes)
    TO_LOC_TYPE VARCHAR2 (15 bytes)
    FROM_LOC VARCHAR2 (12 bytes)
    ITEM_ID VARCHAR2 (25 bytes)
    CASE NUMBER (12.4)
    LMS_UDA1 VARCHAR2 (250 bytes)
    AREA VARCHAR2 (2 bytes)

    I only want to get one record with all the columns, have only one clause MAX (END_TIME)
    But the other column value of the difference.
    When I use MAX (END_TIME) and GROUP OF USER_ID, ID_processus, CASE...
    the sql did not a single record,
    It gives the number of records

    Please help me on this

    Concerning

    Saven

    >
    I only want to get one record with all the columns, have only one clause MAX (END_TIME)
    But the other column value of the difference.
    >
    Maybe it's not possible because it depends on your data.

    If the combination of all columns except END_TIME is not unique then there will be multiple records; a record for each unique combination (GROUP BY) of all other columns.

    The only way to ensure that a record is

    SELECT MAX(END_TIME) FROM myTable
    
  • How to get the dialog box 'Disconnect network drive' with command shell in WIN7?

    I know, when I run the following shell command can get the dialog box "map network drive".

    RUNDLL32 SHELL32. DLL, SHHelpShortcuts_RunDLL connect

    But what is the command to get the dialogue box "Disconnect network drive"?

    Thank you!

    Hello

    Thank you for visiting Microsoft Community.

    I recommend you post your questions on the TechNet Forums for the best and expertise advice. See the link below or more information:

    https://social.technet.Microsoft.com/forums/en-us/home?category=w7itpro&filter=AllTypes&sort=lastpostdesc

  • Can write us "PowerCLI Script" to get the details of card RAID HP (Firmware & Driver)?

    Can write us "PowerCLI Script" to get the details of card RAID HP (Firmware & Driver)

    For example: native ESX command below shows desired output for me.

    But we needed equality PowerCLI ESX command below script

    # cat/proc/driver/cciss/cciss0

    cciss0: HP Smart Array P400i controller

    Board ID: 0x3235103c

    Firmware version: 7.22# cat/proc/driver/hpsa/hpsa0

    hpsa0: HP Smart Array P410i controller

    Board ID: 0x3245103c

    Firmware version: 5,70

    Driver version: HP HPSA driver (v 5.0.0 - 17vmw)

    The extracted following PowerCLI you will get server and type of controller, firmware version and the hpsa/Smart Storage Array controllers driver version based of:

    Get-VMhost | Sort | Select Name, Model,@{N='Controller Type'; E={(Get-VMHostHba -VMHost $_ | ? {$_.Model -imatch '.*(hpsa|smart).*'}).Model}},@{N='Controller Firmware'; E={($_.ExtensionData.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ? {$_.Name -like '*hpsa*firmware*'}).Name}},@{N='hpsa Driver Version'; E={($_.ExtensionData.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ? {$_.Name -like '*scsi-hpsa*'}).Name}} | Format-Table -Autosize
    

    The sample output:

    
    Name                     Model                Controller Type   Controller Firmware                           hpsa Driver Version----                     -----                ---------------   -------------------                           -------------------esxihost1022.local    ProLiant DL380 G6    Smart Array P410i    HP Smart Array Controller HPSA1 Firmware 6.40    Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1023.local    ProLiant DL380 G6    Smart Array P410i    HP Smart Array Controller HPSA1 Firmware 6.40    Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1024.local    ProLiant DL380 G6    Smart Array P410i    HP Smart Array Controller HPSA1 Firmware 6.40    Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1033.local    ProLiant DL360p Gen8    Smart Array P420i    HP Smart Array Controller HPSA1 Firmware 5.42    Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1034.local    ProLiant DL360p Gen8    Smart Array P420i    HP Smart Array Controller HPSA1 Firmware 5.42    Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1041.local    ProLiant DL380 G5    Smart Array P400    HP Smart Array Controller HPSA1 Firmware 7.24    VMware scsi-hpsa 5.0.0-17vmw.500.0.0.469512 2011-08-19 01:58:59.000esxihost1042.local    ProLiant DL380 G5    Smart Array P400    HP Smart Array Controller HPSA1 Firmware 7.24    VMware scsi-hpsa 5.0.0-17vmw.500.0.0.469512 2011-08-19 01:58:59.000esxihost1160.local    ProLiant BL460c Gen8    Smart Array P220i    HP Smart Array Controller HPSA1 Firmware 5.22    Hewlett-Packard scsi-hpsa 5.0.0-40OEM.500.0.0.472560 2012-08-24 21:04:51.000esxihost1161.local    ProLiant BL460c Gen8    Smart Array P220i    HP Smart Array Controller HPSA1 Firmware 5.22    Hewlett-Packard scsi-hpsa 5.0.0-40OEM.500.0.0.472560 2012-08-24 21:04:51.000
    
  • need a script to get the news of VMs who believed map

    Hi guys

    I need a script to get the info of VMs who believed the data center map...

    Like this

    name of the virtual machine

    name of the cluster

    ESXi host ip

    name of the disk... (if it is disk 1 or 2)

    name of the data store

    NNA

    I used the script below, but I am unable to store data name, cluster and host Info

    Get-VM| Get-HardDisk-DiskType "RawPhysical","RawVirtual"| SelectParent,Name,DiskType,ScsiCanonicalName,DeviceName | fl

    Please suggest any modified script to get above information..

    Try like this

    Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" |Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName,  @{N="Datastore";E={$_.Filename.Split(']')[0].TrimStart('[')}},  @{N="VMHost";E={$_.Parent.Host.Name}},  @{N="Cluster";E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}}
    
  • Script to get the name of VMhost among a list of VM?

    Hi people,

    Can anyone here help me scripting by getting the ESXi host name or $vmhost name in the list of the VM?

    Thank you.

    You mean this

    Get-VM | Select Name,@{N="Host";E={$_.Host.Name}}
    
  • I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    Hello

    Can the code below is useful for you, but I do not know how to sort.

    Change the tag based on your employment application.

  • Windows Vista crashes, I get the 'Blue screen of Death' and I have to restart. Different errors each time it crashes.

    Windows Vista crashes, I get the 'Blue screen of Death' and I have to restart. Different errors each time it crashes. I tried to reinstall vista without success of the problem being fixed

    Hello

    Look in the Event Viewer to see if something is reported on those.
    http://www.computerperformance.co.UK/Vista/vista_event_viewer.htm

    MyEventViewer - free - a simple alternative in the standard Windows Event Viewer.
    TIP - Options - Advanced filter allows you to see a period of time instead of the entire file.

    http://www.NirSoft.NET/utils/my_event_viewer.html

    -------------------------------------------------------------------------
    Also this, so you can see the probable bluescreens.

    Windows Vista restarts automatically if your computer encounters an error that requires him to plant.
    http://www.winvistatips.com/disable-automatic-restart-T84.html

    -------------------------------------------------------------------------

    Here are a few ways to possibly fix the blue screen issue. If you could give the info from the blue screen that would be
    Help. Such as ITC and 4 others entered at the bottom left. And any other information such as STOP error
    codes and info like IRQL_NOT_LESS_OR_EQUAL or PAGE_FAULT_IN_NONPAGED_AREA and similar messages.

    As examples:

    BCCode: 116
    BCP1: 87BC9510
    BCP2: 8C013D80
    BCP3: 00000000
    BCP4: 00000002

    or in this format:

    Stop: 0 x 00000000 (oxoooooooo oxoooooooo oxoooooooo oxooooooooo)
    Tcpip.sys - address blocking 0 x 0 00000000 000000000 DateStamp 0 x 000000000

    It is an excellent tool for displaying the blue screen error information

    BlueScreenView scans all your minidump files created during "blue screen of death," collisions
    Displays information on all the "crash" of a table - free
    http://www.NirSoft.NET/utils/blue_screen_view.html

    BlueScreens many are caused by old or damaged drivers, video drivers in particular, but there are other causes.

    You can follow these steps in the Safe Mode if necessary or the command prompt Vista DVD or Options of recovery if your
    system installed by the manufacturer.

    This tells you how to access the System Recovery Options and/or a Vista DVD
    http://windowshelp.Microsoft.com/Windows/en-us/help/326b756b-1601-435e-99D0-1585439470351033.mspx

    You can try a system restore to a point before the problem started when one exists.

    How to make a Vista system restore
    http://www.Vistax64.com/tutorials/76905-System-Restore-how.html

    -------------------------------------------------------------------------

    Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN

    Enter this at the command prompt - sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    The log can give you the answer if there is a corrupted driver. (Says not all possible driver problems).

    Also run CheckDisk, so we cannot exclude as much as possible of the corruption.
    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    -------------------------------------------------------------------------

    Often drivers up-to-date will help, usually video, sound, network card (NIC), WiFi, 3rd party keyboard and
    smile, as well as of other major device drivers.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    How to install a device driver in Vista Device Manager
    http://www.Vistax64.com/tutorials/193584-Device-Manager-install-driver.html

    How to disable automatic driver Installation in Windows Vista - drivers
    http://www.AddictiveTips.com/Windows-Tips/how-to-disable-automatic-driver-installation-in-Windows-Vista/
    http://TechNet.Microsoft.com/en-us/library/cc730606 (WS.10) .aspx

    -------------------------------------------------------------------------

    How to fix BlueScreen (STOP) errors that cause Windows Vista to shut down or restart unexpectedly
    http://support.Microsoft.com/kb/958233

    Troubleshooting, STOP error blue screen Vista
    http://www.chicagotech.NET/Vista/vistabluescreen.htm

    Understanding and decoding BSOD (blue screen of death) Messages
    http://www.Taranfx.com/blog/?p=692

    Windows - troubleshooting blue screen errors
    http://KB.wisc.edu/page.php?id=7033

    -------------------------------------------------------------------------

    In some cases, it may be necessary.

    The Options or Vista recovery disk Startup Repair

    How to do a startup repair
    http://www.Vistax64.com/tutorials/91467-startup-repair.html

    This tells you how to access the System Recovery Options and/or a Vista DVD
    http://windowshelp.Microsoft.com/Windows/en-us/help/326b756b-1601-435e-99D0-1585439470351033.mspx

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • With photoshop 2014 cc 2.0 in edit, fill, pattern, script, I get only 6 options. Trees and executives have disappeared.

    With photoshop 2014 cc 2.0 in edit, fill, pattern, script, I get only 6 options. Trees and executives have disappeared and I only get the filling of symmetry, filling of brick, cross weave, place along the path, random fill and spiral. This is normal or is my corrupted photoshop version?

    options are passed to the FILTER - RENDERED

  • If I have the first generation iWatch I'll be able to get the update for new applications and look at faces?  I know that I couldn't display or the waterproof function to the water.

    If I have the first generation iWatch I'll be able to get the update for new applications and look at faces?  I know that I couldn't display or the waterproof function to the water.

    Hello

    The next operating system update, watch OS 3, will be available for all Apple Watch models, including the first generation watches.

    We should go out on 13 September, after which it can be installed by following the steps detailed here:

    More information:

    http://www.Apple.com/Watchos/

  • Site ads continue to use the proxy settings and I get the message "Authentication required" time and time again. I have stop advertisements to use my proxy settings?

    I have put my school proxy settings and use them very often. On some Web sites, ads continue to use these proxy settings (probably to show me ads based on my preferences or I don't know), and I get the message "Authentication required" time and time again before the end of the loading page. It's annoying because if I have several tabs open and am currently on another page while loading the website with the ads, I'm brought back to this page to authenticate. Can I get asked 3 times to authenticate while this page loads, and it takes forever to load because of this. I don't want to disable my proxy settings because I use it very often. I tried to uncheck the "Accept cookies from Web sites" and nothing happens, it's always the same. I want these ads to stop going through my proxy settings. How do I do that?

    Hello

    You can try the add-on Adblock Plus . In addition to subscriptions, you can manually add URL patterns or click on an ad to add a filter.

    Support

  • My mcbook used to synchronize my iphone6 it again to get the new version on computer and I have the new version of iTunes versionThis (11.4) is the current version.

    My mcbook used to synchronize my iphone6 it again to get the new version on computer and I have the new version of iTunes versionThis (11.4) is the current version.

    iTunes version 12.3.2 is the latest version of iTunes.

    http://www.Apple.com/iTunes/download/

  • How to get the string (specified by row and column) of txt file with labview

    Hello world

    How to get the string (specified by row and column) of txt file with labview

    THX

    As far as I know, a text file has no column.  Be more specific.  Do you mean something like the 5th word on line 4, where the words are separated by a space, and lines are separated by a newline character?  You can read from the spreadsheet String function and set the delimiter to a space.  This will produce a 2D channels table.  Then use the table to index and give the line number and column number.

  • In the notification area, volume, network and power icons have disappeared.

    In the notification area, volume, network and power icons have disappeared. When I go into properties, in the area of system icons the same selections are grey, when I click on them that no check mark. How to make the grey selections to become black (active), so when I click on them the check marks appear?

    [Moved from comments]

    Johnny D.81 responded on November 2, 2012

    Try these steps and check if that helps:

    ** Turn it back on. Sometimes a reboot will solve this problem.* *.

    1. close all programs and stop the laptop.

    2. remove all power supplies (battery and power cord)

    3. empty the remaining power by pressing the power on button for 30 seconds (even if you have no power).

    4. put the battery back and start the computer

    5. once fully loaded, right-click on the system tray and select Properties.

    6. This will bring to the top of the "Taskbar and Start Menu Properties" dialog box. The "Notification area" tab.

    7. at the bottom of the tab, is the area 'icons systems. " There is a checkbox for "Power". "check" the box and click on apply or OK.

    Also update your graphics card drivers.

    It works! Tanks a lot Johnny D.81!

Maybe you are looking for

  • Satellite T110: Where to find software for Win 64 bit Toshiba

    My netbook Toshiba T110 supplied with Windows 7 home 64-bit pre-installed.I have some critical applications that will only run on the 32-bit version, so I downgrade. I ordered a 500 GB hard drive to install the 32-bit version (keeping the original di

  • Linksys WRT330N Wireless Gaming Router

    Hello, I am looking for a game wireless router, and I found the Linksys WRT330N to be what I'm looking for (the fact that it can prioritize packets sent for game purposes). Although it seems not that Linksys makes this product more. So I was wonderin

  • Cannot get past windows security user name and password request window to access messages

    Windows Vista - outlook express. Can not access my e-mail because of the pop-up page without acknowledging my username or password security?

  • E6420 wireless switch

    We had to reload an e6420 so it could be given to another employee. Wireless switch no longer works. The light on the chassis of the laptop does not light regardless of the position of the switch. I checked the BIOS and it is activated. Any ideas?

  • Correction of the problems of color variation (CS6)

    Hey people - pro photog. Here I used CS6 for Mac to edit my images.  Problem is this: the colors look when open in CS6, but when I view on a web browser (Chrome, Firefox, etc.), more often than otherwise, they find themselves looking for dish, deaf a