Script to retrieve logs ESX host

We have a situation where you have to pull up to some log files from each ESX host in a cluster to send...

log files such as esx.conf, and/proc/scsi/ql/ all zipped... for each individual hosts

is there a way that this can be done through the ttookit?

There are currently, as far as I know, no cmdlets in the VITK that allow you to access the local file system of the ESX COS.

But with the plink.exe and sudo command you can get something that comes close.

$User = 
$Pswd = 
$Computer = 
$plink = "\plink.exe"
$plinkoptions = " -v -batch -pw $Pswd"
$cmd1 = 'sudo -u root cat /etc/vmware/esx.conf'

$remoteCommand = '"' + $cmd1 + '"'
$command = $plink + " " + $plinkoptions + " " + $User + "@" + $computer + " " + $remoteCommand

$msg = Invoke-Expression -command $command
$msg | Set-Content "C:\Temp\esx.conf"

In this script, see the esx.conf file and the output is captured and stored in a file on the local file system.

For the sudo configuration, see my notes in allowing AD authentication

Tags: VMware

Similar Questions

  • PowerCLI script to list the df - hl on all ESX hosts?

    Hi Expert,

    I have more than 100 esx host, and I need to list all the df - hl out for my report. Y at - it instead of connect on each esx host to get under output, powercli script that I can use to remove similar information?

    Size of filesystem used Avail use % mounted on

    / dev/sdaa2 20G 1.5 G 17G 8%.

    / dev/CCISS/c0d0p1 1.1 G 118 M 909 M 12% / Boot

    / dev/sdaa6 9.7 G 151 M 9.0 G 2% / Home

    / dev/sdaa7 9.7 G 151 M 9.0 G 2% / tmp

    / dev/sdaa5 9.7 G 317 M 8.9 G 4% / var

    / dev/sdaa8 494M 212 M 257M 46% /vmimages

    Please advice. Thank you

    Are you allowed to enable SSH on servers ESX (i)?

    And are you allowed to establish a SSH session on each ESX (i) Server?

    You have an account and a password on each ESX (i) server that can run the command 'df '?

    If it is Yes, then you can use something like plink.exe in consequence of PuTTY to connect to each ESX (i) server, run the command "df" and retrieve the output.

    There are several available examples to use plink.

    And don't forget that you will need a fingerprint for each server ESX (i) will be stored on the client from which you are running the script.

  • Trying to acquire "tail" result on all of the Cluster Log Files of the ESX host

    Hello everyone!

    I'm trying to design a script that I can use to point to ESX host groups and generate the last 10 lines of the log files specific on these systems by using Get-journal. First of all, I would like to point out that the following code works for a single individual host:

    $esx = get-VMHost - VMhost ""hostname"" " "

    $esxlog = Get-Log -key 'vmkernel' -VMHost $esx

    $esxlog. Entries & lt;


    I had to leave out the expression that specifies the last ten lines of $esxlog. Entries b/c this editor kept interpret this section as html and present it as such

    This will show the expected results, i.e. the last 10 lines of the newspaper on this host.

    Now, when I try to expand this concept and try to create a loop on this basis by using the code below:

    $esx = Get-Cluster "NOMCLUSTER" | Get-VMHost

    foreach ($_ in $esx) {$esxlog = Get-Log -key 'vmkernel' -VMHost $_ }

    $esxlog. Entries} & lt;


    once more the code specifying the last ten lines has been omitted here in order to avoid confusion

    I only get the following error: a parameter corresponding parameter name "System.Object []" cannot be found.

    What I am doing wrong with my script?

    The variable $_ is a predefined variable so that you should not use it as your loop variable.

    You could do it like this

    $esx = Get-Cluster  | Get-VMHost
    $esx | %{
         $esxlog = Get-Log -Key "vmkernel" -VMHost $_
         $nrEntries = $esxlog.Entries.Count
         Write-Host $_.Name -foregroundcolor green
         $esxlog.Entries[http://($nrEntries-11)..($nrEntries-1)|http://($nrEntries-11)..($nrEntries-1)]
    }
    
  • Please share the Script to retrieve the name of host, HBA, HBAstatus, WWN, pathpolicy and dualpathinfo

    Please share the Script to retrieve the name of host, HBA, HBAstatus, WWN, pathpolicy and dualpathinfo

    Take a look on Re: information on the host hardware with information about the HBA drivers and nic

  • Script to count total amount of memory allocated to the VM on each ESX host

    Hello

    I'm looking for a script to add all the RAM allocated to virtual machines per ESX host in vCenter.

    I can quite easily show the MemoryUsageMB and the MemoryTotalMB, but I would like to get the total amount of memory assigned to VM-based host?

    Any help would be appreciated.

    Thank you

    Ben

    Try something like this

    Get-VMhost |Select Name,@{N="Memory used MB";E={  $_ | Get-VM | %{$_.ExtensionData.Summary.QuickStats.HostMemoryUsage} |  Measure-Object -Sum | Select -ExpandProperty Sum}}
    
  • You will need to run the script for some ESX hosts.

    Dear team,

    I m connected to 4 esx host, but I want to run the script only 2 esx host asking you to help me how to do?

    concerning

    Mr. VMware

    You could start the script with the cmdlet Get-VMhost to select only the two hosts that you want to output to. For example:

    Get-VMHost host1, host2. Get - VM

    Displays only the virtual machine running on host1 and host2.

  • 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

  • What is the STIG RSS script and how implement us it with ESX hosts?

    I have heard of STIG script but do not know what he done to the ESX host and what is it and is it necessary? Any ideas would be excellence.

    It is one of the specially designed UNIX script for the Department of defense uses to run against your ESX hosts to any of the configurations and security issues and will generate a report of vulnerabilities.  You can download them directly from the site Web of STIG and run the script to see how vulnerable are your hosts.  Here's a long discussion on this topic and the updated release of the script as it goes.

    http://communities.VMware.com//thread/145435?TSTART=15

    If you found this information useful, please consider awarding points to 'Correct' or 'useful '. Thank you!!!

    Kind regards

    Stefan Nguyen

    iGeek Systems Inc.

    VMware, Citrix, Microsoft Consultant

  • script to retrieve host Syslog parameters

    Dees someone at - it a script to extract the Syslog host settings? The output file must contain the hostname entry and syslog. I don't want to change the settings automatically, I only check to ensure that all guests have an entry.


    Thank you

    Hello, -.

    You can use the Get-VMHostSyslogServer cmdlet to get this info.  As:

    Get-VMHost | %{$oSyslogEndpoint = Get-VMHostSysLogServer -VMHost $_; Select-Object -InputObject $_ `    name,@{n="SyslogSrv"; e={$oSyslogEndpoint.Host}},@{n="SyslogPort"; e={$oSyslogEndpoint.Port}}}
    

    That would have produced something like:

    Name                  SyslogSrv    SyslogPort
    ----                  ---------    ----------
    myHost0    oursyslogSrv.dom.com           514
    myHost1    oursyslogSrv.dom.com           514
    myHost2
    myHost3    oursyslogSrv.dom.com           514
    

    .. where there are no values for SyslogSrv and SyslogPort if the VMHost has not configured Syslog server.  And, if you want to export to a file, you can add "|" Export Csv - UseCulture - c:\temp\VMHostSyslogInfo.txt NoTypeInfo"at the end.  What to do for you?

  • Script PowerShell to enter all hosts ESX MAC address

    I tried to find a way to use powershell to enter all ESX host MAC addresses in a specific data center. If someone has something that can be useful, please let me know. I'm puzzled.

    Is that what you are looking for?

    $dcName = 
    Get-Datacenter -Name $dcName | Get-VMHost  | %{
         $esx = $_
         $_ | Get-VMHostNetworkAdapter | `
              select @{N="ESXname";E={$esx.Name}},DeviceName,Mac
    }
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • How to report the current time on the ESX host in to a csv file with the following

    Hello guys

    I have the script next where I make the required details except the current time on the ESX host. Anyone can guide me please.

    {foreach ($esx to $vmhosts)
    $hostVC = $vcenter
    $hostCluster = $esx. Parent.Name
    $hostHost = $esx. Name
    $ntp = $esx | Get-VMHostNtpServer
    $hostNTP = "$ntp".

    }

    I want to integrate the following for loop of the above for loop and ge the output in a single table.

    foreach ($esxcli in get-vmhost | get-esxcli) {"" |} {Select @{n = "Time"; e = {$esxcli.system.time.get ()}}, @{n = "hostname"; e = {$esxcli.system.hostname.get (.hostname)}}}

    Add-Content - Path '$hostVC, $hostCluster, $hostHost, $hostNTP, $hostTime' $hostInvFile - $ hostTime is where I want to get my host right now.

    I'm vcenter, esx name, name of the cluster, host of the ntp server address, but I need the host thus present.

    Thanks in advance.

    Thank you

    vKar

    Try changing the line where the script retrieves the VMHost to this

    $vmhosts = get-VMHost-State connected. Name sort

    This way the script will be only to ESXi nodes that are "connected".

    Pick up time for those defective does not much sense in all cases

  • Determine which user added an ESX host to vCenter

    I'm trying to figure out if there is anyway to determine which user has added a vCenter ESX host using the api.  I don't see this information as any sort of property of the host object.  Any help would be appreciated!

    Paul

    You can retrieve this and other events by using the event manager and the queryEvents() - http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.event.EventManager.html

    There is no property associated with a host ESX (i) on which the user added to vCenter and since it seems that you are interested in a specific host ESX (i), which can help narrow down the query.

    Attached, that is, remove / add a vSphere SDK for Perl script that will return the user who added the host to vCenter, you should get a response because it uses the Ref object managed the host ESX (i) and that changes each time you have.

    Here is an example of course:

    ./findUserAddHost.pl--serveur root vcenter50-4 - vihost - vesxi50 - 3.primp username - industries.com
    Enter the password:
    added root host vesxi50 - 3.primp - industries.com to datacenter datacenter2

  • Add several NFS data stores to multiple ESX hosts

    I am trying to write a script that will set up several NFS exports to multiple ESX hosts. Here is the script I use, it will add an NFS export to an esx host list.

    $esx = (get-Content servers.txt)

    {}
    $Host_Name = (Read-Host "enter the server (ex: storage-san)")
    $Path = (Read-Host "enter the path (ex: / ds_name/flight/flight)")
    $Name = (Read-Host "Enter the name of the data store")

    {foreach ($server in $esx)
    $Error.Clear)
    Get-VMHost $server | New-Nfs Datastore - NfsHost $Host_Name-path $Path - name $Name | Out-Null
    If ($error.count - gt 0) {$error | out-file ($server, 'c:\powershell scripts\logs\' + '.txt')}
    }

    $add_more = Read-Host "want to show you another data store?
    }
    While ($add_more - eq 'Yes' - or $add_more - eq "y")

    This script actually works OK but I can't just she kick sending and walk. If I have 10 stores of data to add, I have to wait for the current to the end, and then type the information for the second, etc..

    I was hoping just to type all the information from the beginning and the shot of the script to the wide and let him go. Here is what I added, you can see where I'm going with this?

    $esx = (get-Content servers.txt)

    $num_mounts = (Read-Host "Do you have multiple media")
    If ($num_mounts - eq 'Yes' - or $num_mounts - eq "y")
    {
    $mounts = @(Read-Host "supports différents combien avez_vous")

    #prompt me for all the different right monte upwards before and then executed by the actual task of Mount...
    }

    Any ideas?

    Try something like this

    $servers = @()
    $paths = @()
    $datastores = @()
    
    $answer = Read-Host "Enter another NFS mount ?" while($mount -eq "y"){
        $servers += Read-Host "Enter the NFS host"    $paths += Read-Host "Enter the path"    $datastores += Read-Host "Datastore name ?"    $answer = Read-Host "Enter another NFS mount ?"}
    
    $Error.Clear()
    
    Get-Content servers.txt | %{
        $esx = Get-VMHost -Name $_    $countNFS = $servers.Count
        if($countNFS -ne 0){
            0..($countNFS - 1) | %{
                New-Datastore -Nfs -NfsHost $servers[$_] -Path $paths[$_] -Name $datastores[$_] | Out-Null            if($Error.count -gt 0){
                    $Error | out-file ('c:\powershell scripts\logs\' + $server + '.txt')
                    $Error.Clear()
                }
            }
        }
    }
    

    The script reads all the data in the tables.

    Then it loops through all ESX hosts from the servers.txt file, and for each host, it will create all the NFS data storages.

  • cannot remove vMA ESX hosts

    I added a few guests of the vMA and activate the newspaper collection.  It collects logs for the hosts with success.  I don't want to follow these with the vMA hosts more because they are in a remote location and that it would implement a vMA at the remote location.  I use the sudo vifp removeserver servername command to remove the ESX host and they are eliminated as appropriate.  I run the vifp order mailing lists and they appear more more.  The thing is that the newspaper collection is still happening against the machines on the vMA.  I'll look in the directory/var/log/vmware and the directory for the ESX host, I deleted is still there.  I removed the directory and they immediately come with newspapers.  I'm going to rerun the command to remove the host and he says that they are already removed.

    How get rid you of the machines out of the vMA?

    You must use vilogger to disable the first control, and then remove the targets of vMA. Looks like vilogger works regardless of what VMAs think its management.

    If you have removed the targets of MAS... should not be able to connect to your targets from a distance. Are you sure that the log data is always transferred or is it simply a directory being created?

    There is a local credstore that is stored in the home directory of vi-admin /home/vi-admin/.vmware/credstore, perhaps you may need to disable it (make a backup first and move or rename)

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

    William Lam

    VMware vExpert 2009

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

    repository scripts vGhetto

    VMware Code Central - Scripts/code samples for developers and administrators

    150 VMware developer

    Twitter: @lamw

    If you find this information useful, please give points to "correct" or "useful".

  • List of virtual machines on an ESX host

    Is there a method in the sdk that lists all the virtual machines on an esx host?

    Simply get a reference to a HostSystem and it has an array property called vm http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.HostSystem.html that gives you a reference to a matrix to all virtual machines on this particular host.

    Here is a sample Perl script that shows how to retrieve all the virtual machines for a specific host and certain attributes of the VM: getAllVMGuestHostname.pl

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

    William Lam

    VMware vExpert 2009

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

    repository scripts vGhetto

    VMware Code Central - Scripts/code samples for developers and administrators

    150 VMware developer

    Twitter: @lamw

    If you find this information useful, please give points to "correct" or "useful".

Maybe you are looking for