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.
Update November 9th 2022:
- removed PSSnapin loaded test
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.
The use of the script is quite easy (we think). A short overview of a typical session:
- Start the script
- In the vSphere Server text-box enter the name or IP address of an ESXi or a vCenter server.
- Click the Connect button.
- If the connection is successful, the line below the vSphere Server text-box will display the version of the vSphere Server.
- The Events box will list all the events that exist on the vSphere server.
- The number of events that are found will be displayed just above the Events box.
- When you hover over a specific event, the description of the event (if present) will be displayed in a pop-up box.
- You can also use the Name and Description radio-buttons to switch between the eventname and it’s description.
- 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.
- When you select an event by clicking on it, the event will appear in the Selected box.
- When you click on an event in the Selected box, the event will be removed.
- When all the required events are selected, click the Generate Code button. The code will be stored in the clipboard.
- 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.
- 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.