Script to pull the last timestamp spend all hosts in a cluster?

Hi all

Lately I have seen an issue where my host 5.1 logging abruptly stops and the other remote access to every host I have no way of knowing what happened.

Is it possible to account for the last, for example hostd.log timestamp for each host in a cluster?

Thank you

Tony

Try something like this

foreach($esx in Get-Cluster -Name MyCluster | Get-VMHost){  $log = Get-Log -Key hostd -VMHost $esx  $esx | Select Name,@{N="Last entry";E={[datetime]($log.entries[-1].Split(' ')[0])}}}

But be aware that fetch a newspaper of the ESXi could take some time.

The script needs get the full log, to be able to extract the last line

Tags: VMware

Similar Questions

  • PowerShell script to change the DNS entries for all hosts

    Ive tried many others which have been posted on the web and none work... Someone at - it a script to change the DNS entries on all hosts?

    OK, changed a few pieces my end, it worked but now it's... Try this (50% confident

     $dnsServers = ("192.168.111.3","192.168.111.4")
    
     Get-VMHost | Get-View | %{
        $ns = Get-View -Id $_.configManager.networkSystem
        $dns = $ns.networkConfig.dnsConfig
    
         $dns.Address = @()
         foreach($server in $dnsServers) {
           $dns.Address += $server
       }
       $ns.UpdateDnsConfig($dns)
     }
    

    If you found this information useful, please consider the allocation of points for correct or helpful.

    Alan Renouf

    http://Virtu-al.NET

  • script to pull the VMTools version for all of the VM?

    Do we have the script to extract the VMTools version for all the virtual machines?

    with powershell, you can use:

    Get - vm | Get-View | Select Name, @{Name = "VMWareToolVersion"; {Expression = {$_.config.tools.toolsversion}}

    or:

    Get - vm | Get-VMGuest | Select VMName Toolsversion

    with esxcli I would do it similar to (sorry, but I don't know the syntax of the shell):

    Vim - cmd vmsvc/getallvms | SED ' 1 of | AWK '{print $1}' (to gett all the VM ID)

    then for each ID I would do this:

    Vim - cmd vmsvc/get.config 12 | grep-i toolsversion

  • Stop/Fix "Please insert the last disk of all selfextracting and click OK to continue.

    (With the help of Win 7 32 - bit update)

    I have not used a disk of 3.5 inches for many years.  In addition, I have not used any device (USB, CD or DVD) that has / had problems of "whole selfextracting.

    Also, AutoPlay was disabled on my system for years.

    That said, whenever I do a search of file/folder I get "Please insert the last disk of all selfextracting and click OK to continue.

    How can I be to determine:

    1. What causes the error message and/or
    2. How to stop it forever!

    Thanks for any thoughts or ideas!

    DennisCPA

    Don't know if you've discovered this done yet for you, but I would say it is your usb flash drive. It happens when he is out BEFORE you used the 'Safely remove' icon on the taskbar.

    If it is, then you must copy any information on the USB key to another location and format the USB. Then you can copy the info on it and you're right to go!

    This will continue to happen sometimes even though you have the properties/policies defined in a quick deletion. I got mine the value of the radio button performance and ALWAYS use the icon REMOVE safe in your taskbar. Once you find that your data will be corrupted if is not removed properly, even if the ssd is supposed to be "hot." If you have a usb key that has a light on it, wait for the light to STOP BLINKING before removing it. If you do not have a light on this issue, it is always advisable to wait a second or two after the popup window say you that it is save to remove your USB.

    See you soon

    Glenn

  • OK, Adobe, why am I constantly being logged onto my CC account? I can't use the software when it maintains the bombing. The problemhas who spends all day and he killed my workfow - HELP

    OK, Adobe, why am I constantly being logged onto my CC account? I can't use the software when it maintains the bombing. The problemhas who spends all day and he killed my workfow - HELP

    Wish I had read this post before posting. Or ran the spellchecker...

    Anyway, people treated at Adobe callcentre solved the problem. Make sure you connect to the CC of the desktop application. So, good job Adobe...

  • PowerCLI Script required to identify all clusters in a data center and all hosts within each cluster and calculate it using cpu and ram, avg, min, and max.

    Hi all

    I'm new to powercli and try to create a script to list all clusters in a data center and all hosts in a cluster and calculate min, max and avg cpu usage and ram by the host and cluster. So far, I have tried the below but I can't publish the results of my script.

    $Function = @)
    ForEach ($DataCenter Get-Data Center)
    {
    ForEach ($cluster in ($DataCenter |)) Get - Cluster)) - need help to post the information here and confirm if this is correct or not.
    {
    ForEach ($hosts in ($cluster |)) Get - VMHost))
    {
    ForEach ($vms to ($hosts |)) Get - VM)) - do not know if I called you here functions properly
    {
    $allvms = @)
    $allhosts = @)
    $hosts = get-VMHost
    $vms = get - Vm

    {foreach ($vms in $hosts)
    $hoststat = "" | Select the host name, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin
    $hoststat. Host name = $vmHost.name

    $statcpu = get-Stat-entity ($vmHost) - start (get-date). AddDays(-30)-Finish (Get-Date) - MaxSamples 10000 - stat cpu.usage.average
    $statmem = get-Stat-entity ($vmHost) - start (get-date). AddDays(-30)-Finish (Get-Date) - MaxSamples 10000 - stat mem.usage.average

    $cpu = $statcpu | Measure-object-property value - average - Maximum - Minimum
    $mem = $statmem | Measure-object-property value - average - Maximum - Minimum

    $hoststat. CPUMax = $cpu. Maximum
    $hoststat. CPUAvg = $cpu. Average
    $hoststat. CPUMin = $cpu. Minimum
    $hoststat. MemMax = $mem. Maximum
    $hoststat. MemAvg = $mem. Average
    $hoststat. MemMin = $mem. Minimum
    $allhosts += $hoststat
    }
    }
    }
    }
    }

    $Function | Select the host name, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin | Export-Csv "c:\Function.csv" - noTypeInformation

    Any help on this is much appreciated.

    [Ordered] casting was introduced in v3 PowerShell.

    For PowerShell v2, you can use

    $vms = get - VM

    $stat = 'cpu.usage.average ','mem.usage.average '.

    $start = (get-Date). AddDays(-31)

    $report = get-Stat-entity $vms - start $start - Stat $stat - ErrorAction SilentlyContinue |

    Group-object - property {$_.} @entity.name} | %{

    $cpu = $_. Group | where {$_.} MetricId - eq "cpu.usage.average"} | Measure-object-property value - average - Maximum - Minimum

    $mem = $_. Group | where {$_.} MetricId - eq "mem.usage.average"} | Measure-object-property value - average - Maximum - Minimum

    New-object PSObject-property @ {}

    Datacenter = Get-Datacenter - VM $_. Group [0]. Entity | Select the name of ExpandProperty-

    Cluster Cluster Get - VM = $_. Group [0]. Entity | Select the name of ExpandProperty-

    VMHost = $_. Group [0]. Entity.Host.Name

    Name = $_. Group [0]. @entity.name

    CpuMin = $cpu. Minimum

    CpuAvg = $cpu. Average

    CpuMax = $cpu. Maximum

    MemMin = $mem. Minimum

    MemAvg = $mem. Average

    MemMax = $mem. Maximum

    }

    }

    $report | Sort-Object-property Datacenter, Cluster, VMHost name |

    Export Csv report.csv - NoTypeInformation - UseCulture

  • Create a VMFS and add it to all hosts in a cluster

    Hi, I'm trying to create a script in order to create a data store and then present it to all hosts in a cluster.

    any idea?

    Add-PSSnapin "Vmware.VimAutomation.Core".
    # - Create Variables -
    #$vcenter = %1
    ##---Connexion to the VirtualCenter-
    $Server = $args [0]
    $ClusterName = $args [1]
    $VMHost = {get-Cluster $ClusterName |} Get-VMHost}
    $Name = $args [2]
    $Path = $args [3]
    SE connect-VIserver $Server

    Get-VMHost $VMHost | New-store data-Server $Server - name $Name - path $Path - Vmfs-confirm: $false
    Get-VMHostStorage - $VMHost - RescanAllHba - RescanVmfs-r VMHost

    You must be connected to the Cluster Get

    You need not create the data store on all nodes of the cluster.

    Just 1 host is sufficient.

    And the creation of a new store of data forces a new analysis.

    So that should be enough

    Add-PSSnapin "Vmware.VimAutomation.Core" ## ----Créer les  Variables----#$vcenter = %1## ----Connexion au VirtualCenter---- 
    
    $Server = $Args[0]$ClusterName = $Args[1]
    
    Connect-VIserver $Server
    
    
    $VMHost = Get-Cluster $ClusterName | Get-VMHost | Select -First 1 
    
    $Name = $Args[2] $Path = $Args[3]  Get-VMHost $VMHost | New-Datastore -Server $Server -Name $Name -Path $Path -Vmfs -Confirm:$false
    
  • Script to add the layer mask to all layers but the background?

    I have been a professional editor/Retoucher for photographers for the past three years. I use a lot of stock, but I've never branched in scripts so far. I am trying to refine my workflow and scripts to not appear to be the next logical step.

    I do a lot of work in the interiors, which is essentially manual HDR. Here's my current generation process, which I would love to find a way to script. I tried to be very clear, but let me know if it needs to expand. I use Photoshop CS5.

    1. pull brackets, color corrected TIFF in Bridge.

    2 re-order as needed, with the main exhibition downstairs. Click on 'Tools' > 'Photoshop' > 'Charge in the form of layers Photoshop"to get a PSD with layers in the correct order and main as exposure layer from bottom (base).

    3. manually go through each layer and add a layer mask hide all each layer except the background layer.

    4. Save as a PSD, using the original name of the background layer as the file name. To do this, I just copy the name of the layer (example.tiff), paste in the Save dialog box and then use the drop-down menu to select PSD (save as example.psd).

    I hope to automate steps 3 and 4 as they are the majority of your time for me. Any contribution is appreciated!

    Thanks again.

    Yes, your change is good.  This way the last layer will not have a mask applied.  I wasn't sure if you wanted that, but in the control for the background layer.

    Regarding the economy, what file format would you save on?  Here's how to save a psd:

    docRef var = activeDocument

    var doneFolder = new Folder('/c/photos/')

    var NomCouche = docRef.activeLayer.name

    var psdOptions = new PhotoshopSaveOptions();

    psdOptions.layers = true;

    app.displayDialogs = DialogModes.ALL;//include this line if you want that the coming dialog box.

    docRef.saveAs (new file (doneFolder + "/" + NomCouche + ".psd"), psdOptions);

    app.displayDialogs = DialogModes.NO;//Resets at ALL - you won't let it work on.

  • DNS query script - need a way to script to query the DNS settings of all the servers on a domain

    Hi - I was wondering if anyone new a script or a simple way to query the DNS settings of all the servers on a domain? Basically, I need to know the primary and secondary, all our servers DNS settings and that discharge into a file. Any help is very appreciated

    Thanks in advance

    Hello

    As you try to run the DNS settings on the domain, I suggest you to post the same question on the Microsoft TechNet Forums

    You can follow the link to your question:

    Windows Small Business Server: http://social.technet.microsoft.com/Forums/en/category/windowsserver/

    It will be useful.

  • When you rename a file change the last timestamp consulted?

    I was in a heated debate with one of my instructors today associated with a test on the access timestamp question when you rename a file. Through my research and testing to rename a file via the command prompt, it does not appear that the process of renaming a file will change the date of that last file access. Access and modify times will change to the directory that contains the file, but not the file itself.  So my understanding is that it is not, however, my instructor insists that it is, can someone shed some light on this topic please?

    Reading material more - it's interesting.

    More information under:

    Windows NT keeps track of three stamps of time associated with files and directories. These three temporal are written in creation, last access, and last. When a file or directory is created, accessible or changed, Windows NT updates the appropriate time stamp.

    http://support.Microsoft.com/kb/148126/a

    NTFS uses the change log to track information on the added files, deleted and changed for each volume.

    http://TechNet.Microsoft.com/en-us/library/cc938919.aspx

    Working with file systems

    http://TechNet.Microsoft.com/en-us/library/bb457112.aspx

  • Transfer photos from camera to PC: photo library no matter the last photos - just all THE pictures...

    I'm trying to transfer photos from my phone to my PC camera. Normally, Windows Photo Gallery simply matter most recent photos from the last time. It is important now that each peak on my device (more than 400 photos). Can anyone advise how to either my (Nokia N95) device or PC simply import the most recent photos and not every pic that exists on the device? All solutions are greatly appreciated.

    Hi Homeister,
     
    1. don't you make changes before the show?
     
    We recommend that you cross check if the target location to store/save image files is intact.
    We also recommend you to reset a default file arrangement and check the result.

    Check if the problem continues in a new user account.
    1. open user accounts by clicking the Start button, clicking Control Panel, clicking user accounts and family safety, then clicking on user accounts.
    2. click on manage another account.  If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.
    3. click on create a new account.
    4. type the name you want to assign to the user account, click an account type, and then click on create an account.

    For more information, see this link: http://windows.microsoft.com/en-US/windows-vista/Create-a-user-account
     
    See "how to make photos from my camera to my computer?
    http://Windows.Microsoft.com/en-us/Windows-Vista/how-do-I-get-pictures-from-my-camera-to-my-computer
     
    Windows Photo Gallery: frequently asked questions: http://windows.microsoft.com/en-US/windows-vista/Windows-Photo-Gallery-frequently-asked-questions
     
    I hope this helps.
     
    Kind regards
    Syed
    Answers from Microsoft supports the engineer.

  • script to insert the new master on all other pages

    I have an indesign document with 131 pages (front of postcards). I should add the back of the postcard (master) for all other pages. I don't want to do it manually because of the time and that I will need to do this again. Someone at - it a script that will allow insertion of still blank pages on pages of numbered and then I can apply the master page to all pages?  Something will help you. Thank you!!

    Just found out that the script on this forum http://forums.adobe.com/message/3223771#3223771#3223771 does it perfectly.

  • Reset the NTP Service on all hosts

    Hi all.

    I've been in it for almost thirty years and people always tell me I should learn the "language X." they tell me it will save me time and aggrivation.  Of course, the most recent is Powershell, and since I am woriking in tVMWare, PowerCLI infrastructure any type of following along.  So when I sit, looking at what should be a relatively simple script, spinning my wheels waste ime more that it would take to just do it manually in the GUI!  So here I sit feeling my blood pressure elevation and wonder why I bother to try this shit!  Sorry for ranting a bit, but maybe someday someone will invent a language that really SIMPLIFIES them THINGS!

    My task was simple.  Change the NTP server on our VMWare hosts entries.  So I found a script in one of the forumns, and although he was 'logic' (Yes!) to restart the service after the change is made, it did not do that, then this morning, I went looking for a code to do just that last piece.  I found a script on the blog of Simon Long which looked pretty simple, and I was able to follow the logic of the orders.  So I stuck in a script and edited to my environment.

    Here's the script.

    $Hosts= Get-VMHost

    ForEach($Hostin $Hosts)

    {

    Remove-VmHostNtpServer-NtpServer"<old ntp server>" -VMHost $Host| Out-Null

    Add-VmHostNtpServer-NtpServer"<new ntp server>" -VMHost$Host| Out-Null

    Get-VmHostService-VMHost$Host | Where-Object {$_.key -eq "ntpd"} | Restart-VMHostService-Confirm:$false| Out-Null

    write"NTP Server was changed on $Host"

    }

    Given that I had already changed the host at the new address, I deleted the first two lines of the loop.  I he started with a connect-viserver, saved command, ran and he bombed on the foreach loop, stating that $host was read-only and could not be changed.  I DIDN'T ASK TO CHANGE IT!  So, I'm about to PowerCLI and rename it UselessPOS yet another!  Can someone give me logical som REAL as to why he thinks that it should alter this variable?

    Your script is all right, just change the name of the loop variable.

    Something like this for example

    $Hosts=Get-VMHost

    ForEach($esxin$Hosts)

    {

       Remove-VmHostNtpServer-NtpServer""-VMHost$esx|Out-Null

       Add-VmHostNtpServer-NtpServer""-VMHost$esx|Out-Null

       Get-VmHostService-VMHost$esx|Where-Object{$_.key-eq"ntpd"} | Restart-VMHostService-Confirm:$false|Out-Null

       write"NTP Server was changed on $esx"

    }

  • License question - do need me a VSAN license for all hosts in a cluster?

    I have a 6 host cluster exist using the VSphere Essentials Plus package with a single server VCenter. Can I buy x VSAN 3 licenses, for example to add the storage to the 3 hosts I have install the VSAN license on and access the VSAN of the 3 other hosts in the cluster data store? (Assuming only 1 CPU for each host.)

    Thank you!

    Hi Daniel,.

    Since Virtual SAN is activated at the level of a cluster, all cluster hosts can consume storage since the virtual SAN data store regardless of how many guests contribute to storage. So to answer your question, you need all 6 hosts in your cluster license, even though only 3 of them contributed storage.

    Also note that the licenses are per CPU so in your scenario if each host has 2 CPUs, you need a total of 12 CPU licenses. I hope this helps.

    Chris

  • Good way to stop all hosts in a cluster

    I have a small environment with 2 esxi hosts in a cluster. my company will have 2 planned outages that I need to close all the servers down including the esxi hosts. What is the right way to do this to make sure that everything is properly turned off and no vmotion will trigger that everything will be turned off?

    Thank you!

    Welcome to the community - the order you need to shute down is:

    1. Stop the virtual machines
    2. Put the hosts in MAintenance mode
    3. Stop hosts
    4. Stop vcenter (if vCenter is a virtual machine, you will need to connect to each host separately and close).

    To put it all together

    1. Start the hosts
    2. Begin to vCenter

Maybe you are looking for

  • HP 15 laptop: hp 15 screen problem r blue

    HI, I JUST BOUGHT hp 15 product number r: LOE96A #ABV AND its been 3 months and each time each time I doo a few navigation heavy or some work as software development. the laptop display a blue screen with an error in driver_IRAQL_NOT_LESS_OREQUAL (rt

  • Messages no longer allows me to transfer images using AIM

    For ten years my colleagues and I have used iChat, then Messages to Exchange images for work (we use AIM ). A year or two (maybe more) we could no longer transfer pictures back. The recipient has never been an alert seeking a file to send to them, bu

  • change the text unit-error bounds 1128

    Hey everybody, I develop a VI that uses the native power of LabVIEW units to do all the conversions of my numbers. Here my question, once variables are defined for a control when editing can I change the text of unity to something not related to exec

  • PRESS ESC AT STARTUP MENU (PROBLEM)

    When I RESTART my computer [pavilion dv6c16nr] laptop it says press ESC KEY TO START MENU but when I press the esc/ESC key nothing happens pls help me solve this problem. a big thank you to this site and more power!

  • The unit content config.xml 6.0 problem

    HelloWhen I change the confing.xml ' miapp