It works like this:
First, it would like to know what string you are looking for. Maybe it’s the name of a virtual machine, maybe the word Error, maybe a specific date and time (note however that each log has it’s own date / time format).
Then it tries to check whether or not you are connected to a server already by looking at the value of the $DefaultVIServer variable. (If you have a definitive way to determine whether or not you’re connected: let me know in the comments.) If you’re not connected, the script will ask which server to connect to. You can connect to Virtual Center Servers or ESX Servers.
Then it checks which log files are available. It will loop through all of them, checking if your search string is found.
It then displays the most recent matches found. You can modify the $maxResults value in the script to adjust it to your needs.
Hope it’s Helpful!