Get-vievent formatted output

Hello Luke,.

Instead of the select-object cmdlet, I would use format-table - Autosize. If I do this, I can only direct to cmdlet convertto-html I want. What is the trick here? I need an output formatted due to FullFormattedMessage.

$fileloc = "c:\error.csv".
$vievents = get-VIEvent-start (Get-Date). AddHours(-24)-Types 'mistake ' |
Select-object Createduserid, username, FullFormattedMessage |
Export-Csv-path $fileloc - NoTypeInformation - UseCulture

Thank you

You must use a Format-* cmdlet only as the last cmdlet in a pipeline. The Select-Object cmdlet is used to select only the properties that you want. To better keep this cmdlet. You can convert the output to html format with:

$a = ""

Get-VIEvent -Start (Get-Date).AddHours(-24) -Types "Error" |
Select-Object CreatedTime, UserName, FullFormattedMessage |
ConvertTo-HTML -head $a -body "

VI Events Information

" | Out-File VIEvents.htm Start VIEvents.htm

Best regards, Robert

Tags: VMware

Similar Questions

  • Export of Get-VIEvent event

    Hello

    I found the get-vievent command output looks like this

    model: false

    key: 8240

    chainId: 8240

    Createduserid: 2009-03-23 14:38:03

    user name:

    Data Center: VimApi.DatacenterEventArgument

    computeResource: VimApi.ComputeResourceEventArgument

    Host: VimApi.HostEventArgument

    VM: VimApi.VmEventArgument

    fullFormattedMessage: Machine virtual viedfs1-clone is connected

    dynamicType:

    dynamicProperty:

    It is possible to get there real name of the host instead of the value VimApi.HostEventArgument?

    What I'm trying to do is to get the list of errors and warnings with time stamp, name the source (host or guest) and completely formatted message. Perfect example is event VC GUI export

    Error 2009-01-30 12:43:20 cannot communicate with a primary agent of HA cluster Cluster1 in Test environment

    error 30/01/2009 12:43:20 abcd.fqdn.com host in Test environment does not

    It is possible to reproduce the logfile that way by VI toolkit?

    Thnx a lot

    The following should do what you want.

    Note that I have export text to a CSV file, which makes it easier to see the different areas

    
    $report = @()
    get-vievent -Types Error,Warning -Start (Get-Date).addminutes(-15) | %{
      $row = "" | Select Time, Text, Host
      $row.Time = $_.CreatedTime.ToString()
      $row.Text = $_.fullFormattedMessage
      if($_.host -ne $null){
         $row.Host = $_.host.name
      }
      else{
        $row.Host = ""
      }
      $report += $row
    }
    $report | Export-Csv "C:\report.csv" -noTypeInformation 
    

    Post edited by: LucD

    Just noticed I put 1500 instead of 15 as an argument to the addminutes method.

  • Get - vm | Get-vievent email html output

    Hello world

    I am having trouble pushing results table in an object and then adding the members of the object to an array.  I have had success using the slot method in the past, but I've only tried (previously) with a cmdlet.  In the example below, I'm piping several cmdlets.  Basically, $vms outputs very well, but I can't get any instantiated table to fill later.  The $mainArray will always send as null in the email.  Any ideas?  I really don't want to get vievent in the foreach loop, as it will really slow down the query.

    SE connect-viserver test.testdomain.com

    $mainArray = @)

    $userArray = @)

    $timeArray = @)

    $msgArray = @)

    $CDT = get-Date

    $vms = get - VM | Get-VIEvent-Types of information - start $CDT. AddDays(-30)-finishing $CDT | Where {$_.} GetType(). Name - eq "VmBeingDeployedEvent" - or $_. GetType(). Name - eq "VmCreatedEvent" - or $_. GetType(). Name - eq "VmRegisteredEvent"} | Select the username, Createduserid, FullFormattedMessage | Format-Table - AutoSize

    foreach ($vm to $vms)

    {

    $username = $vm. Username

    $createdTime = $vm. Createduserid

    $msg = $vm. FullFormattedMessage

    $userArray += $username

    $timeArray += $createdTime

    $msgArray += $msg

    }

    For ($i = 0; $i - lt $userArray.Count; $i ++)

    {

    $item = new-Object PSObject

    $item | Add-Member-type NoteProperty-Name "UserName" - value $userArray [$i]

    $item | Add-Member-type NoteProperty - name "time created" - value $timeArray [$i]

    $item | Add-Member-type NoteProperty-Name 'Message' - value $msgArray [$i]

    $mainArray += $item

    }

    "$Head = @".

    < style >

    TABLE {border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse ;}}

    TH {border-width: 1px; padding: 3px; border-style: solid; border-color: black; background-color: #6495ED ;}}

    TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black ;}}

    < / style >

    "@

    # #begin send e-mail section.

    $comp = get-wmiobject win32_computersystem

    $mailFrom = $comp.name

    $FromAddr = $mailFrom + "@testdomain.com.

    $ToAddr = " " [email protected] "" "

    $Subject = "Virtual machines created in the last 30 days"

    $SMTPServer = "smtp.testdomain.com".

    $Body = $mainArray |  ConvertTo-Html-head $Head | Out-string

    Send-MailMessage-to $FromAddr - to $toAddr - subject $Subject - body ($body) - BodyasHtml - SmtpServer $SMTPServer

    disconnect-viserver-confirm: $false

    Why if complicated, what follows should give the same result.

    SE connect-viserver test.testdomain.com

    $mainArray = @)

    $CDT = get-Date

    $mainArray = get - VM | Get-VIEvent-Types of information - start $CDT. AddDays(-3)-finishing $CDT | Where {$_.} GetType(). Name - eq "VmBeingDeployedEvent" - or $_. GetType(). Name - eq "VmCreatedEvent" - or $_. GetType(). Name - eq "VmRegisteredEvent"} |

    Select @{N = 'Username'; E={$_. User name}}.

    @{N = "time created"; E={$_. Createduserid}},

    @{N = 'Message'; E={$_. FullFormattedMessage}}

    "$Head = @".

    "@

    # #begin send e-mail section.

    $comp = get-wmiobject win32_computersystem

    $mailFrom = $comp.name

    $FromAddr = $mailFrom + "@testdomain.com.

    $ToAddr = "[email protected]".

    $Subject = "Virtual machines created in the last 30 days"

    $SMTPServer = "smtp.testdomain.com".

    $Body = $mainArray |  ConvertTo-Html-head $Head | Out-string

    Send-MailMessage-to $FromAddr - to $toAddr - subject $Subject - body ($body) - BodyasHtml - SmtpServer $SMTPServer

    disconnect-viserver-confirm: $false

  • host name of output of get-vievent filter

    Hi guys,.

    I have a question about the host name filtering in an output of get-vievent. for example, I tried to extract only the host name of the following command:

    Get-VIEvent - maxsamples 20000 | where {$_.} GetType(). Name - eq "VmRemovedEvent"} | Sort descending Createduserid | Select FullFormattedMessage

    Already tried some things like split and toppings, but this does not work for me.

    The name of the server is always based on a ground known as SERVER-< description >.

    Sure. For the removed VM also is just an additional line of PowerCLI:

    Get-VIEvent -maxsamples 20000 |
    where {$_.Gettype().Name -eq "VmRemovedEvent"} |
    Sort CreatedTime -Descending |
    Select @{N="VMHost";E={$_.Host.Name}},
      @{N="VM";E={$_.Vm.Name}}
    
  • Get-VIEvent command line options

    Hello list,
    Options of I have a question about the command line for Get-VIevent. I need to get the logs between a given time limit. I'll use this command in a script. If I can make use of Get-Date command output to - Start - Finish settings.
    I have to get the logs between a given time limit. for example I need newspapers between 16:00 to 17:00 on the same day. for that I do use Get-Date command output?
    Thank you
    Ghislain

    Ghislain wrote:

    This way to grep for a particular string. I know there is an option called "findstr". can you please cite the use of this option of findstr?

    There are a few (dozen) different ways to approach this problem in PowerShell. I hope these examples help:

    PS > $a = Get-VIEvent
    PS > $a | group { $_.GetType().BaseType }
    
    Count Name                      Group
    ----- ----                      -----
       20 VimApi.AlarmEvent         {13875, 13874, 13873, 13872, 13853, 13852, 13846, 13845, 13809...
        8 VimApi.SessionEvent       {13871, 13870, 13869, 13823, 13816, 13815, 13813, 13812}
       65 VimApi.VmEvent            {13868, 13867, 13866, 13865, 13864, 13863, 13862, 13861, 13860...
        2 VimApi.HostEvent          {13821, 13819}
        3 VimApi.Event              {13820, 13818, 13784}
        1 VimApi.GeneralEvent       {13817}
        1 VimApi.CustomFieldDefE... {com.icomasoft.PowerScripter.script}
    
    PS > $a | Where-Object { $_.key -eq 13875 }
    
    source               : VimApi.ManagedEntityEventArgument
    entity               : VimApi.ManagedEntityEventArgument
    from                 : gray
    to                   : green
    alarm                : VimApi.AlarmEventArgument
    key                  : 13875
    chainId              : 13845
    createdTime          : 12/7/2008 11:17:27 AM
    userName             :
    datacenter           : VimApi.DatacenterEventArgument
    computeResource      : VimApi.ComputeResourceEventArgument
    host                 : VimApi.HostEventArgument
    vm                   : VimApi.VmEventArgument
    fullFormattedMessage : Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green
    dynamicType          :
    dynamicProperty      :
    PS > $a | ? { $_.fullFormattedMessage -match "memory" } | select -first 5 | ft key, full* -auto
    
      key fullFormattedMessage
      --- --------------------
    13875 Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green
    13873 Alarm Virtual Machine Memory Usage on vcenter.halr9000.com changed from Gray to Green
    13853 Alarm Virtual Machine Memory Usage on vcenter.halr9000.com changed from Green to Gray
    13846 Alarm Virtual Machine Memory Usage on openfiler changed from Green to Gray
    13809 Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green
    

    [PowerShell MVP |] [ https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], the VI Toolkit forum moderator

    Author of the forthcoming book: VMware Infrastructure Management with PowerShell

    Co-host, PowerScripting Podcast (http://powerscripting.net)

    Need help in General, other than VMware PowerShell? Try the PowerShellCommunity.org forums

  • How do I see the full message with the command Get-VIEvent

    Hello list,

    I was trying to see the VIevents with the command get-vievent as below

    Get-VIEvent-type error - MaxSamples 20 | Format-Table Createduserid, FullFormattedMessage - autosize

    In this case, if it's a great message, the fullFormattedMessage displays incomplete messages (for example/error found on & lt;) ESX IP & gt; in & lt; Centre for data & gt ;...) ... what should I wear to display the full message with the command Get-VIevent?

    Thank you

    Krishnaprsad

    This is the Format-Table cmdlet, which shows only a part of the message.

    If you want to see the full message, you could do

    Get-VIEvent -Type Error -MaxSamples 20 | %{Write-Host $_.CreatedTime $_.FullFormattedMessage}
    

    The alternative is to adapt the formatting instructions in the VMware.VimAutomation.Format.ps1xml file.

    But that could impact other cmdlets and is a bit more complicated.

  • Anyone know where I can get a formatting tool to format an external hard drive to FAT32?

    Anyone know where I can get a formatting tool to format an external hard drive to FAT32 using OEM of Windows 7 (32 bit).

    I want to use a Western Digital elements external Hard Drive 500 GB/GB on my Panasonic Blu RAY recorder DMR-BW850.

    Formatting on W7 tool reformatted hard drives only as exFAT, who does not work, works only FAT32.

    original title: FAT32 formatting help

    Throw on this article. This can be easily done from the command prompt.

    http://www.online-tech-tips.com/computer-tips/formatting-external-hard-drive-to-FAT-32/

    Remember that you cannot store a file that is greater than 4 GB on a FAT32 partition.

  • Look at a record events with get-vievent

    How can I use get-vievent to see everything that follows?

    -All exports of VMS in vCenter

    -All exports of virtual machines in an ESXi host

    -All downloads of files vmdk to a store of data using client operations or copy of Vmware on the vmdk from the dcui / ssh console?

    The idea is to see every time a vmdk left the environment.

    You can report export (EGGS or OVF) with the following

    $start = (get-Date). AddHours(-1)

    Get-VIEvent-Start $start - MaxSamples ([int]: MaxValue) |

    where {$_-is [VMware.Vim.TaskEvent] - and $_.Info.DescriptionId - eq "VirtualMachine.ExportVmLRO"} |

    Select CreatedTime,UserName,@{N='VM'; E={$_. UMM name}}, FullFormattedMessage,

    @{N = 'Event'; {E = {$_.Info.DescriptionId}}

    Download files through the browser data store does not all events as far as I know.

  • Get-VIEvent "vSphere HA restarted virtual machine.

    Hi score

    Can someone help me complete this script

    Get-Cluster 'test ' | Get - VM | Get-VIEvent | Where-Object {$_.} FullFormattedMessage-LIKE "{vSphere virtual machine rebooted HA *'} |" Select ObjectName,@{N="IP addr; E={($_. Guest.IpAddress)}}, Createduserid, FullFormattedMessage

    Out put:

    ObjectName IP addr Createduserid FullFormattedMessage

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

    VM1 05 - Sep - 14 16:14:29 vSphere restarted my virtual HA...

    VM2 05 - Sep - 14 16:14:25 vSphere restarted my virtual HA...

    VM3 05 - Sep - 14 16:14:25 vSphere restarted my virtual HA...

    Failed to get the IP address on this script.

    Thank you for giving if any good script to get vSphere HA restarted event when the host failure.

    Try like this

    Get-Cluster 'test ' | Get - VM |

    Get-VIEvent |

    where {$_.} FullFormattedMessage-match 'vSphere virtual machine rebooted HA'} |

    Select ObjectName,@{N="IP addr; E = {(Get-vue-Id $_.)} {{Vm.Vm). Guest.IpAddress}}, Createduserid, FullFormattedMessage

    Not sure property you are trying to achieve with ObjectName.

  • Install the problem. I get the error output code: 1603 which is not listed on the help site

    Install the problem. I get the error output code: 1603 which is not listed on the help site. All of the solutions that is the meaning?

    Error 1603 http://helpx.adobe.com/creative-suite/kb/error-1603-install-cs3-cs4.html

  • Events not shown in get-vievent

    What types of events are NOT displayed in

    Get-vievent?

    For example, suppose that a user connects to a server ESXi directly, rather than connecting to vCenter Server.  This ESXi server is managed by the vcenter Server.  Everything is done on the ESXi server can still to report through

    '

    Get-vievent

    the server vCenter Server?

    What could be missing if I don't

    Get-vievent - username 'ADDOMAIN\adusername '.

    the server vCenter for this user?

    Server ESXi and vCenter server have their own set of events.

    As you can easily check with my Event-O-Matic script, when you connect to a server ESXi and vCenter server.

    ESXi events, both there are connectivity, are copied to the vCenter by the vpxa service that runs on the ESXi.

    So in theory you should, as far as I know, see all ESXi appearing in the vCenter events events & tasks

  • Get-VIEvent to find the name of vm?

    Hello

    Is it possible to get the name of the vm get-vievent?

    I'll try to find all the VMS created in the last day (easy), then get - vm... basic idea...

    Get-VIEvent - maxsamples 20000 - Start (Get-Date). AddDays(-1) | where {$_.} GetType(). Name - eq "VmBeingDeployedEvent | VmCreatedEvent | VmRegisteredEvent | VmClonedEvent"} | Select the username, Createduserid, FullFormattedMessage |
    % {get - vm $vm}

    Thanks for the help!

    I don't watch carefully your Where clause, it should be like the code above.

    Please try like this.

  • Filtering some results in Get-VIEvent

    How would be to filter the results of Get-VIEvent or other specific keywords in the FullFormattedMessage, or by the MessageInfo property?

    I'm trying to use Get-VIEvent to get a list of warning and error events and want to filter the "insufficient result of RAM video.

    I am trying to filter either by the insufficient "vidéo RAM" text in the property of FullFormattedMessage, or the result of "{msg.svgaUI.badLimits}" in the MessageInfo property.

    Thanks in advance for any help.

    Hello, aydeisen-

    You can use a statement Where-Object to filter the events as you wish.  As:

    Get-VIEvent | Where-Object {    ($_.FullFormattedMessage -like "*Insufficient video RAM*") -or    ($_.MessageInfo | ?{$_.id -like "*msg.svgaUI.badLimits*"})} ## end where-object
    

    This verifies VIEvents whose FullFormattedMessage property is as the given string, or whose MessageInfo property (which is zero or more objects of VirtualMachineMessage ) is an VirtualMachineMessage object with the id as the given string property.

    Of course, you will use the other Get-VIEvent settings for changing the scope of the events gathered initially (for a given entity, a time limit given, maxSamples, etc.).  How does do for you?

  • Get-VIEvent question

    I'm trying to generate a list of all users who are connected.  I have this command and it works, but I would exclude 1 or more users of this list, which is "root".

    Here is the command I use.

    $events = get-VIEvent - MaxSamples 1000

    foreach ($event in $events) {if ($event.fullFormattedMessage - match '(.*)@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b connected the user') {Write-Host ('User' + $matches [1] + "" connected to: "+ $event.createdTime")}}

    Hi, mchunger,

    This should work for you, if you know the names you want to exclude:

    $excl = @(«root», «admin», «dcui»)

    foreach ($event in $events) {if ($excl - notcontains $event.username) {if ($event.fullFormattedMessage - match '(.*)@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b connected the user') {Write-Host ('User' + $matches [1] + "" connected to: "+ $event.createdTime")}}}

    Kind regards

    Ogniana

  • Don't PowerCLI v5 changes that behaves in the way that get-vievent?

    Hi all

    I just installed v5 powerCLI and some scripts I was using don't work anymore.

    the get-vievent-start (get-date command).adddays(-2) that I have used to analyze events in the course of the last 2 days, is now back only a few events, all of the current day.

    is - anyone notice the same behavior?

    Hello, nicolasbouyssy-

    Hmm, strange.  So, if you run the line of your script that gets the desired events and count the number of items that it returns is - this superior to the default value of 100?  In other words, something like:

    (Get-VIEvent -Start (Get-Date).AddDays(-2)).Count
    

    I understand wanting to have things run fast.  Can possibly restrict you the events that you retrieve by specifying an array of entities for which to get the events (using parameter - entity), either by limiting the event types with the parameter - Types (to represent types of error, Info, or Warning)?

    Regarding, "unless it is smart enough to stop navigation when the date is reached" - Yes, it must be the behavior when you use the MaxSamples parameter with - Start - it will return up to MaxSamples number of events, but none is older than the specified start date.  So, if there are 100000 events, but only 2200 in the past two days, specifying for MaxSamples 100000 with a start of two days should return only 2200 events.

    As for fixing the MaxSamples number to cover all events - I assumed that to be sure that you get all you can, you can use the maximum value for MaxSamples.  It's a [int32], whose maximum value is 2,147,483,647 (which is (2 ^ 31) - 1).  So to be sure you have found all the events gave as you can, you can use this maximum value for MaxSamples, as such:

    Get-VIEvent -MaxSamples 2147483647 -Start (Get-Date).AddDays(-15)
    

    Or, using mathematics (maybe for readability):

    Get-VIEvent -MaxSamples ([Math]::pow(2,31) - 1) -Start (Get-Date).AddDays(-15)
    

    But, filtering of events on some of the other things mentioned above (type, entity) apparently is a good idea before the entry to get about 2 ^ 31 events...

Maybe you are looking for

  • HP Envy 23: HDMI in button does not work in Windows 10

    After the upgrade to Windows 10, the button used to display HDMI no longer works on my HP Envy 23

  • Phone for iPhone/iOS companion

    What is the name of the iPhone/iOS app for the use of the software Lenovo phone Companion on the laptop to control & use features of phone as SMS, pictures, etc.. ? Thank you

  • Which allows a Boolean variable being true in a while loop

    Hello. I have 12 real switches. The default value of them is false, and I need to somehow allow one of them turn out every time. To clarify, if for example I click on don't pass any 2 (and turn it to true) to start its ok, because that is only turned

  • My line in order to work for onboard audio or added sound card, how can I fix?

    Win XP SP3. No sound can be heard, or saved from, line input on the its Audigy SE card or on board Sound Max.  I'm 100% sure the cable (several have been tried) a sound source (several were found to be) works correctly and plugged into the correct li

  • CD tray does not open

    I manually closed my CD tray, after turning off the PC. Now, it will not be open. I damaged it? I tried to use a paper clip in the small hole, but still no response. A few whirring noises but no action.