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 September 7th 2013:
- added at least PowerShell v3 test
- added PowerCLI core pssnapin loaded test
I rarely post about products, since I want to keep my blog “technical“, but there was some big news from Idera today.
As from version 4.6, their famous PowerShell Plus editor is now a free tool.
This is the editor I have been using to write, and debug, my PowerShell and PowerCLI scripts since day 1.
It would take me several pages to list the features I like and use in PowerShell Plus, but there are 2 that were ‘love at first sight’ for me; the Debug mode and the Variables pane. You can’t go without those when you are writing a script.
So why not give it a try, it’s for free now
Today was a historic day for the Belgian VMUG.
The 17th edition, the so-called “Blogger Edition“, was completely sold out. All 170 attendees, a new record, had a great day and the presenters all gave a peak performance. The list of presenters was impressive to say the least.
I was honored to have been selected to do a presentation as well. Since it was in Belgium, I decided to give the subject of my session a local twist. The subject was PowerCLI and beer, you can’t live without them.
You’ll be missing the story I told during the presentation, but on request, the slides.
Update: all presentations are now available here (requires a VMUG account).
There seem to be many vSphere environments where the same foldername is used multiple times. A blue folder with the name Servers is quite common for example.
If you need to retrieve such a folder with the Get-Folder cmdlet, you will have to walk the path to the folder leaf by leaf and use the Location parameter. It would be handier if you could just specify the path to the folder and retrieve the folder like that.
The following is a small function that will allow you to do just that.
Lately I have been playing around with the new Storage related features in vSphere 5. One of the novelties is that you can now unmount a VMFS datastore and detach a SCSI LUN through the API.
To be able to unmount a datastore, some conditions have to be met. In the vSphere Client you get an informative popup that tells what is prohibiting the datastore unmount. If not all conditions are met, you can not continue with the unmount.
Nice feature, but what for those of us that want to automate this ?
Update October 28th 2012: Take into account that the datastorecluster is not connected to a host that is part of a cluster. Skip the HA heartbeat test.
Update April 23th 2012: Use the RetrieveDasAdvancedRuntimeInfo method to find the actual datastores that are used for the heartbeat.
Recently I had the pleasure of doing a guest post, called Finding your way in the PowerCLI Community, on the PowerCLI blog. The subject of the post was how to find community threads, that might hold an answer to your question.
Now this wouldn’t be a PowerShell/PowerCLI blog, if I didn’t try to automate the procedure. And with a serious amount of RegEx involved, I was able to create some working code. Here it is, my Find-VMTNPowerCLI function.
Warning: pure PowerShell, no PowerCLI content !
I got an interesting question from one of my co-authors of the PowerCLI Reference book. He was looking for a method to find the port used by a VM when connected to a portgroup on a dvSwitch.
Finding the answer to that question is not too difficult, once you know which property holds the value. But while writing and testing the script, I thought that this question would be a good opportunity to show several ways and methods that you have at your disposal in PowerCLI and PowerShell, to come to a solution.
Here it goes.
There was an interesting thread in the PowerCLI Community today. It raised the question how one could report on the current vCenter sessions, including the IP address or hostname from where the session was started.
Unfortunately the SessionManager doesn’t hold any information from where the session was started.
But there are other ways of finding that information. The UserLoginSessionEvent object has a property, called ipAddress, that has the information we’re after.
Btw if you are only interested in looking for idle sessions, independent from which host they were started, there is a great post, called List and Disconnect vCenter Sessions on the PowerCLI blog.
Update May 4th 2012: function updated to handle multiple vCenter connections.
The Invoke-VMScript cmdlet can be a very useful cmdlet, but sometimes it will fail against one or more of your VMs. And it is not always immediately clear why the Invoke-VMScript cmdlet will not work against that specific VM.
The cmdlet help contains a number of prerequisites, but how do you verify if all the prerequisites are fulfilled?
I decided to create a function that would verify the prerequisites, and that would, if requested, which of the prerequisites was missing.
In the vCenter Client, since vSphere 4, you can find a Storage Views tab on several of the VI containers. The data in these Storage Views is collected and provided by the vCenter Storage Monitoring plug-in.
Have a look at David Davis‘s post, called Using VMware vSphere Storage Views, for more information on what you can do with the Storage Views.
Some time ago I got a question from Andrew how the Multipathing Status presented in the Storage Views could be detected and reported upon by a PowerCLI script. What looked rather simple at first, turned out to be a bit more difficult than I anticipated.