Event-O-Matic

One of the questions, related to working with vSphere events and tasks, that often appear in the PowerCLI Community, is how do we know which events to select for a query.

To make that task a bit easier, I wrote the Event-O-Matic script. It’s a GUI that allows you to pick a number of events, and the script will generate the PowerShell code, and place it in the clipboard. The Event-O-Matic script was mentioned during our VMworld 2013 US session VSVC4944.

event-o-matic-3-2

Update September 7th 2013:

  • added at least PowerShell v3 test
  • added PowerCLI core pssnapin loaded test

The script presents a GUI based on Windows Forms. The PowerShell code to generate the GUI was created by the Sapien PrimalForms Community Edition.

Due to the size of the script, I did not place the complete script inline in this post, but rather I provided a download link. Make sure to “unblock” the script after you downloaded it, to avoid problems with the PowerShell execution policy.

Event-O-Matic
Event-O-Matic
Event-O-Matic-v3_2.ps1
Version: 3.2
21.1 KiB
Details...

The use of the script is quite easy (we think). A short overview of a typical session:

  1. Start the script
  2. In the vSphere Server text-box enter the name or IP address of an ESXi or a vCenter server.
  3. Click the Connect button.
    1. If the connection is successful, the line below the vSphere Server text-box will display the version of the vSphere Server.
    2. The Events box will list all the events that exist on the vSphere server.
    3. The number of events that are found will be displayed just above the Events box.
  4. When you hover over a specific event, the description of the event (if present) will be displayed in a pop-up box.
  5. You can also use the Name and Description radio-buttons to switch between the eventname and it’s description.
  6. You can search for text that should appear in the Name or Description field. Enter the text in the Search text box and click Search. The Events window will now only show the events that have the specific text in the Name of in the Description field.
  7. When you select an event by clicking on it, the event will appear in the Selected box.
  8. When you click on an event in the Selected box, the event will be removed.
  9. When all the required events are selected, click the Generate Code button. The code will be stored in the clipboard.
  10. By default the code generator uses the Get-VIEvent cmdlet, but by selected the Get-VIEventPlus switch, you can generate code that uses the Get-VIEventPlus function. See my Get the vMotion/svMotion history post for the Get-VIEventPlus function.
  11. The Finish button is self-explaining I assume.

During our VMworld US 2013 session, we showed a short video that demonstrated the use of the script.

Enjoy !

5 Comments

    ozgr

    Hello Lucd,
    I can’t download Event-O-Matic-v3_2.ps1. Can you this link “http://www.lucd.info/download/Event-O-Matic-v3_2.ps1”
    Thank you.

      LucD

      Seems to be working for me.
      Could it be a security measure on your side?

      I placed a copy in PasteBin. Does that work for you?
      Event-O-Matic

        ozgr

        I could this link. Thank you.

    Sagar

    Hey LuCD,

    The script connects to vcenter, but throws bulk of errors and show 0 events.
    I am connecting to vCenter 5.0u2. Here are the errors –

    You cannot call a method on a null-valued expression.
    At C:\data\Event-O-Matic-v3_1.ps1:192 char:26
    + $script:eventTab.Add <<<< ($tabKey,$_)
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept
    ion
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\data\Event-O-Matic-v3_1.ps1:13 char:33
    + $script:eventTab.GetEnumerator <<<< ()| Sort-Object -Property Key |
    + CategoryInfo : InvalidOperation: (GetEnumerator:String) [], Run
    timeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

      LucD

      @Sagar, it looks like you are not using PowerShell v3, or higher, to run the script.
      I added some tests, for the PowerShell version and the presence of the PowerCLI core pssnapin, in the new version 3.2 of the script.
      That should avoid the long list of errors you saw.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Buy the Book