1 2 Previous Next 16 Replies Latest reply on Sep 23, 2020 12:49 PM by avagham

    get-vievent

    dhanu2k7 Enthusiast

      Hi

       

      i am pulling events 5 month old but when I run below command it returns nothing

       

      get-cluster -name xxxxx | Get-VIevent -Start 04/01/2017 -Finish 08/31/2017 -maxsamples 10000 | Where {$_.FullFormattedMessage -match "VMtools|VMware Tools"} | select @{Name='host';E={$_.Host.name}}, @{N='user';E={$_.UserName}},@{N='Createdtime'; E={$_.CreatedTime}}, @{N='Fullmessage';E={$_.FullFormattedMessage}} |export-csv report.csv

       

      I also tried  -match  "Tools" but even then it returns nothings, I belive something wrong script where date is not picked up?

        • 1. Re: get-vievent
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          Try like this.
          If the time formats are different in your culture, you might have to adapt the strings.

           

          $start = Get-Date "01/04/2017"

          $finish = Get-Date "31/08/2017"

           

          Get-VIevent -Start $start -Finish $finish -MaxSamples ([int]::MaxValue) |

          Where {$_.FullFormattedMessage -match "VMtools|VMware Tools"} |

          select @{Name='host';E={$_.Host.name}},

              @{N='user';E={$_.UserName}},

              @{N='Createdtime'; E={$_.CreatedTime}},

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

          Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          1 person found this helpful
          • 2. Re: get-vievent
            dhanu2k7 Enthusiast

            I need to run against cluster as there are multiple cluster

            is this something below is OK?

             

            $start = Get-Date "01/04/2017"

            $finish = Get-Date "07/30/2017"

             

            Get-cluster -Name xxxxx | Get-VIevent -Start $start -Finish $finish -MaxSamples ([int]::MaxValue) |

            Where {$_.FullFormattedMessage -match "VMtools|VMware Tools"} |

            select @{Name='host';E={$_.Host.name}},

                @{N='user';E={$_.UserName}},

                @{N='Createdtime'; E={$_.CreatedTime}},

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

            Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

            • 3. Re: get-vievent
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Use the Entity parameter

               

              $start = Get-Date "01/04/2017"

              $finish = Get-Date "31/08/2017"

               

              $entity = Get-Cluster -Name xxxx

               

              Get-VIevent -Entity $entity -Start $start -Finish $finish -MaxSamples ([int]::MaxValue) |

              Where {$_.FullFormattedMessage -match "VMtools|VMware Tools"} |

              select @{Name='host';E={$_.Host.name}},

                  @{N='user';E={$_.UserName}},

                  @{N='Createdtime'; E={$_.CreatedTime}},

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

              Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

               

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              1 person found this helpful
              • 4. Re: get-vievent
                dhanu2k7 Enthusiast

                its returns nothing in report.csv no error also, I am running against 6 month data for vmware tools update, i am sure there is definitely events are there but i am unable to pull

                • 5. Re: get-vievent
                  LucD Guru
                  vExpertUser ModeratorsCommunity Warriors

                  Did you try without the Entity parameter?

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  1 person found this helpful
                  • 6. Re: get-vievent
                    dhanu2k7 Enthusiast

                    Sorry without entiry also it returns immediate result without any text in report.csv

                    • 7. Re: get-vievent
                      LucD Guru
                      User ModeratorsvExpertCommunity Warriors

                      Which events are you trying to fetch?

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      1 person found this helpful
                      • 8. Re: get-vievent
                        dhanu2k7 Enthusiast

                        I am trying get who installed vmware tools on each VM...

                        • 9. Re: get-vievent
                          LucD Guru
                          User ModeratorsCommunity WarriorsvExpert

                          Afaik installing, or upgrading, VMware Tools does not generate an event.

                          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                          1 person found this helpful
                          • 10. Re: get-vievent
                            dhanu2k7 Enthusiast

                            But there is task which says Vmtools intiated ( after mounting ISO), I would like to see that

                            • 11. Re: get-vievent
                              LucD Guru
                              Community WarriorsUser ModeratorsvExpert

                              Yes, that is a TaskEvent, but it only shows VMware Tools updates, not installs.

                              The Get-VIEvent cmdlet is not recursive for the Entity parameter.

                              That is why we have to specify the VMs on the cluster, and not the cluster itself.

                               

                              Try like this

                               

                              $start = Get-Date "01/04/2017"

                              $finish = Get-Date "31/08/2017"

                               

                              $entity = Get-Cluster -Name xxx | Get-VM

                               

                              Get-VIevent -Entity $entity -Start $start -Finish $finish -MaxSamples ([int]::MaxValue) |

                              Where {$_ -is [VMware.Vim.TaskEvent] -and $_.Info.Name -eq 'UpgradeTools_Task'} |

                              select @{Name='host';E={$_.Host.name}},

                                  @{N='Cluster';E={$_.ComputeResource.Name}},

                                  @{N='user';E={$_.UserName}},

                                  @{N='Createdtime'; E={$_.CreatedTime}},

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

                              Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

                               

                              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                              1 person found this helpful
                              • 12. Re: get-vievent
                                avagham Enthusiast

                                Hello LucD - can we add Vcenter info in CSV file? if we are running script across multiple vcenters? 

                                Thank you!!! 

                                • 13. Re: get-vievent
                                  LucD Guru
                                  User ModeratorsCommunity WarriorsvExpert

                                  Try adding this calculated property on the Select.

                                   

                                  @{N='vCenter';E={([uri](Get-View -Id $_.Entity.Entity -Property Client).Client.ServiceUrl).Host}}
                                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                  1 person found this helpful
                                  • 14. Re: get-vievent
                                    avagham Enthusiast

                                    Hello LucD - Thanks for your help. As per recommendation I've used below command and it is working fine.

                                     

                                    $csvline.vcenter = ([uri](Get-View -Id $event.VM.VM).Client.ServiceUrl).Host

                                    1 2 Previous Next