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

Tags: VMware

Similar Questions

  • Need powershell scripts to collect information from vm disk

    Hello

    I need two scripts to collect information from vm drive,

    1 script to collect information vm disk mode

    Expected results:

    The virtual computer name. Name of ESX. Cluster name | VMDK name | Device label. disksizeInGB | diskmode

    Disc-> Just need the info as persistent or independent_persistent mode

    2. script to collect info RDM of Vm

    Expected results:

    The virtual computer name. Name of ESX. Cluster name | DeviceName | File name | Compatibility mode | Size

    The first script

    Get-VM | %{
         $vm = $_
         $vm | Get-HardDisk | %{
              $_ | select @{N="VM";E={$vm.Name}},
                   @{N="ESX";E={$vm.Host}},
                   @{N="Cluster";E={(Get-VMHost $vm.Host | Get-Cluster).Name}},
                   @{N="VMDK";E={$_.Filename}},
                   @{N="Device Label";E={$_.Name}},
                   @{N="disksizeInGB";E={"{0:N1}" -f ($_.CapacityKB/1MB)}},
                   @{N="Diskmode";E={$_.Persistence}}
         }
    } | ft -AutoSize -Force
    

    ____________

    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 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...

    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 extract VM-&gt; IP-&gt;-&gt;-&gt; 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

  • 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

  • Help with the Powershell script to collect logs from all domain controllers

    I am writing a script to retrieve the last 5 days of application, security and log files from all domain controllers. The script runs, but fire the logs from the local server only. The variable $Computer has all of my DC so it's the fine mark. I guess it's a problem with my line ForEach-Object, but is not error. See the below script.

    $log = 'application '.
    $date = get-date-format MM-DD-YYYY
    $now = get-date
    $subtractDays = new-object System.TimeSpan 5,0,0,0,0
    $then = $Now.Subtract ($subtractDays)
    $Computers = get-ADDomainController-filter *.
    ForEach-Object - InputObject $Computers - process {Get-EventLog - LogName $log - after $then - before $now - EntryType error | select EventID, MachineName, Message, Source, TimeGenerated |} ConvertTo-html | {Out-file $env:TEMP\Applicationlog.htm}
    Invoke-Expression $env:TEMP\Applicationlog.htm

    Thank you

    Rich

    Hello

    To help with the repost the question script to the script Center Forum

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

  • Need to obtain information from a host distributed switch

    Hi all

    I want to get information distributed switch of a host.

    With the script below am able to get the name of the switch, network cards added to the dvswitch and its status.

    $report = @()
    foreach ()$sw in (Get-VirtualSwitch -distributed)) {}
    $uuid = $sw. ExtensionData.Summary.Uuid
    $sw . ExtensionData.Config.Host | %{
    $portStates = $sw. ExtensionData.FetchDVPorts ($null)
    $esx = Get-View $_. Config.Host
    $netSys = Get-vue $esx. ConfigManager.NetworkSystem
    $netSys . NetworkConfig.ProxySwitch | where {$_. Uuid -eq $uuid} | %{
    foreach ($pnicSpec in $_. Spec.Backing.PnicSpec) { }
    $row = "" | Select Host, dvSwitch, Teddy bear, PortLinkUp
    $row . Host = $esx. Name
    $row .dvSwitch = $sw. Name
    $row . PNic = $pnicSPec. PnicDevice
    $row . PortLinkUp = () $portStates | {$_. Clé - eq $pnicSPec. UplinkPortKey}). State.RunTimeInfo.LinkUp
    $report += $row
    }
    }
    }
    }

    $report


    But I would like to get the information of physical switch (switch. physical name and port information of each vmnic connected to this host please help to get the same thing.)

    Note:

    CDP information are enabled.

    Since you have the natachasery, it would be a matter of using a script like Re: how to get the CDP in Switch Cisco values? for the information of the COP.

  • 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}}
    
  • Did not backup VCenter VM with space in name and the virtual created from ESX host computer

    Hi all

    Have worked on the backup of VMware VM ESX 4.1,5.1.5.5 for nearly a year and now I'm familiar Vsphere API (VADP), VDDK API,.

    Now, I'm working on the same implementation by using the credentials of vCenter it works very well up there in the name of VM space.

    VDDK API fails to open the disc with the error code VIX_E_FILE_NOT_FOUND 4, I studied on it, the problem is with "vmpath", the setting is mandatory when using VDDK with vCenter.

    vmpath is in cnxParams and it specifies the owner of the particular disc vm.

    vmpath format is "vmpath = DatacenterName/vm/VMname" for example. 'vmpath = myDC/vm/testVM' it works perfectly

    but the problem is when it's likevmpath = myDC/vm/test VM"i.e. the space in my VM name and then fails.

    I use VDDK 5.5.4 and vCenter 6.0 because it is compatible with the other.

    Thank you and best regards,

    Dipak Poirier

    Please provide a code snipped, including the full command. This could make things more clear.

    André

  • Powershell scripts need to collect info ESX storage

    Hello

    I need three scripts to collect information from ESX storage as shown below

    1. information on the hardware-storage & gt; to collect information on the SCSI controller and HBA cards.

    ESX name | | SCSI controller HBA1 | HBA2

    Expected results

    ESX name | SCSI (model, Bios version, serial number, Raid config) | HBA1 (model, Firmware version, serial number, WWPN) | HBA2 (model, Firmware version, serial number, WWPN)

    Note: Need info on all controllers SCSI and HBA in the ESX box, so additional columns may be added as required.

    2. report on the use of storage - & gt; Usage report storage including local file system storage and SAN devices.

    ESX name | | File system Size | Opportunity | DISP | Use% | Mount point | Scopes

    Note: Need of all sizes in the UK. Extensions are applicable to data SAN storage and just the DiskID measure as vmhba1:1:1

    3 San disk information - & gt; To collect information on San Disk

    Disc ID | Lun ID | Size of the disk | Brand/model | Paths | Policy |     Active HBA WWPN

    Expected results

    vmhba1:1:1 | 0110 | 130 G | EMCxxxx | 4 | Fixed | xxxxxxxxxxxxxxx

    There was an error, you cannot delete items from a hash table by looping through the values.

    Try this one (it works for me).

    $nrMax = 10
    $taskHash = @{}
    
    Get-Cluster  | Get-VM | %{
      $spec = new-object VMware.Vim.VirtualMachineConfigSpec;
      $spec.cpuAllocation = New-Object VMware.Vim.ResourceAllocationInfo;
      $spec.cpuAllocation.Shares = New-Object VMware.Vim.SharesInfo;
      $spec.cpuAllocation.Shares.Level = "Normal";
      $spec.cpuAllocation.Limit = -1;
      $spec.cpuAllocation.Reservation = 0;
      $task = Get-View ($_.Extensiondata.ReconfigVM_Task($spec))
      $taskHash[$task.Info.Key] = $task
      while($taskHash.Count -eq $nrMax){
            $toBeRemoved = @()
            foreach($task in $taskHash.Values){
                $task.UpdateViewData()
                if("success","error" -contains $task.Info.State){
                    $toBeRemoved += $task.Info.Key
                }
            }
            $toBeRemoved | %{
                 $taskHash.Remove($_)
            }
      }
    }
    
  • Help display information from the data store

    Hi, I'm trying to format a table with information from various commands, and I can't find out how to do it.

    Basically I want the table to have the following information:

    ESX host - DatastoreName - CanonicalName - CapacityMB - MultipathPolicy

    The problem is the get-scsilun cli annoys me only the canonical ability and multiple trips, but I want to add the other get-vmhost and get-datastore information

    The command I'm ussing is:

    Get-vmhost | Get-ScsiLun | WHERE-object {$_.} Seller - eq "EmC" - and $_. LunType - eq 'disc'} | Format-Table-property CanonicalName, CapacityMB, MultipathPolicy-auto | Out-String-width 120

    No idea how to do that?

    Thanks in advance!

    Pablo. -.

    Try something like this

    $report =@()
    
    foreach($esx in get-vmhost){
        foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk | where-object {$_.Vendor -eq "EMC"})){
            foreach($ds in (Get-Datastore -VMHost $esx)){
                $ds.ExtensionData.Info.Vmfs.Extent | %{
                    if($_.diskName -eq $lun.CanonicalName){
                        $row = "" | Select Host,DS,CanonicalName,CapacityMB,MultiPathPolicy
                        $row.Host = $esx.Name
                        $row.DS = $ds.Name
                        $row.CanonicalName = $lun.CanonicalName
                        $row.CapacityMB = $lun.CapacityMB
                        $row.MultiPathPolicy = $lun.MultipathPolicy
                        $report += $row                }
                }
            }
        }
    }
    
    $report | ft -AutoSize
    

    The link between the data store and the logic unit number is done by comparing canonicalname the LUN with each canonicalname of the extent of the disk of the data warehouses.

  • 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.

Maybe you are looking for

  • Firefox does not allow me to copy and paste the content of Web sites. How can I solve this problem?

    When I enter this site, there are some areas that FIrefox will allow me to copy and paste. However, if the content is in the pictures, I get a message indicating that options copy/cut/paste is not available in Mozilla and Firefox. Then, the info box

  • Satellite A500D-10F - audio USB is cracking/nervous during playback

    Hello! I am having some problems with my USB Audio on my Toshiba A500D-10F.The sound is cracking/nervous during playback of the sounds all. Even the sound system when the computer is idle. I tried two devices USB (Creative Arena USB Headset and Sandb

  • Tecra M2 - will not start, the power light is on

    Hi, I wonder if someone out there could help me with a problem? I was using my M2 Friday when my friend accidentally hit a very small amount of beverage on the front of my M2, I immediately got up and got a hair dryer on it. After leaving it an hour

  • The size of the menu bar

    I am doing some testing with the functions of the Parent/child window in Windows.  At this point, just trying to see what I can do and see I can perform some basic window using manipulations, and then I'll do it in a more formal tool.  One of the thi

  • Setting up IP static to some Ports on the router.

    On a v4.3 can BEFSR41 I configure static IP for specific to the rear ports.  For example, Port 1 (at the back of the router) = 192.168.100.20, Port 2 = 192.168.100.21, etc..  I don't want to set static IP on the PC connect, but I want to know that th