Create VMFS datastores on “free space” partitions

The New-Datastore cmdlet allows you to easily create VMFS datastores on a free LUN or local disk. But what if you want to create a VMFS datastore on that free partition you have left on a LUN or on a local disk ? These free GBs could come in handy and it’s a shame letting them go to waste. Unfortunately, the New-Datastore cmdlet doesn’t have an option (yet) to handle “free space” partitions.

Exactly such a question was raised by Alasdair in his thread new-datastore on ESX4i Installable local disk in the PowerCLI Community recently.

Continue reading Create VMFS datastores on “free space” partitions

Events – Part 8 – vMotion history

Another idea triggered by a post in the PowerCLI Community. Lars wanted to know where his VMs had been running in the past.

Since vSphere doesn’t maintain any historical data with the guests themselves, we have to fall back on the Tasks and Events to create such a report. The basic algorithm to query the tasks, and their related events, is already published in Events – Part 3 : Auditing VM device changes. But to get a historical record of the servers where your guests have been hosted requires a bit more logic in the script.

Continue reading Events – Part 8 – vMotion history

Script ‘esxupdate -query’

I received an interesting comment on my Events – Part 7 : Working with extended events – Update Manager post from Suresh. He wanted to know if it was possible to create a similar report with the vCenter Update Manager PowerCLI cmdlets as you can get with the esxupdate query command.

Continue reading Script ‘esxupdate -query’

Debugging function – verbose vpxd logging

Today Steve Jin published a post called How to Enable ESX Server Logs for Troubleshooting. A very useful tip when you are looking for those hard-to-find “features” in your script.

Steve’s tip  reminded me that I have a similar small function in my toolchest to do something similar for the vCenter log.

The function allows you to switch the vCenter log between “warning” and “verbose” on the fly. No need to go into the vCenter client to change the logging option anymore while debugging.

Continue reading Debugging function – verbose vpxd logging

Find unused portgroups in a cluster

Triggered by a recent post, see get-virtualportgroup, in the PowerCLI Community, I had a closer look at the Get-VirtualPortgroup cmdlet.

This cmdlet returns a VMware.VimAutomation.Types.Host.VirtualPortGroup object, which contains a very useful property called Ports. In that property it lists all the guests that are connected to a port on the portgroup. That would be the solution to find unused portgroups, I thought. But while the vSphere Client also shows powered off guests that are connected, the Port property returned by the Get-VirtualPortgroup cmdlet doesn’t. 🙁

So the question at hand required a bit more scripting than I originally thought.

Continue reading Find unused portgroups in a cluster

PowerCLI and the SDK – part 3 – Steve Jin’s best practices

Steve Jin, author of the VMware VI and vSphere SDK: Managing the VMware Infrastructure and vSphere book, recently started his DoubleCloud blog. In a short time span he produced several high quality posts which should be a must-read for every SDK user.

In his latest post, Top 10 Best Practices Using VMware VI and vSphere SDK (part 1), Steve gives invaluable advice for working with the SDK.

Since most of the SDK samples are (still) in Java, and since I know there are quite a few SDK users coming from the PowerCLI world, I decided to write up on some of Steve’s best practices for PowerCLI users.

And I hope Steve doesn’t mind 😉

Update: I thought it would make it easier for the reader to group all the SDK best practices and tips & tricks together. So I created a dedicated page, see SDK.

Alarms – Cody’s Abandon Ship

Yesterday, Cody published on his Professional VMware blog an excellent article, called vSphere Host Died Abandon Ship! – vSphere vCenter Alarms & Actions.

The article shows a very elegant solution how to move your guests to “safer havens”, the moment one of the hosts in the cluster starts experiencing hardware problems.
The elegance of Cody’s solution is that he uses maintenance mode to force vMotion on all the powered-on guests on the host that experiences HW problems.

Continue reading Alarms – Cody’s Abandon Ship

PowerCLI and the SDK – Part 2 – Prepare the trip

When I publish scripts that use SDK properties or methods, one of the questions that comes back regularly is “Where do you find what to use ?“.
Let me assure you, there are no tricks, optical illusions or black magic involved. I’m simply using the numerous resources that are made available in the VMware Developer community.
Diving into the SDK is like making a big trip, you have to start prepared !
Continue reading PowerCLI and the SDK – Part 2 – Prepare the trip

Events – Part 4 : Who started that VM ?

In a comment on my Events – Part 3 : Auditing VM device changes post, Ian asked if it was possible to report who started a VM.

To take away the suspense, yes that can be done by using the information from two of my earlier post.

Poweredon-report

Since I considered it a bit too long to give the solution in a comment, this post.

Continue reading Events – Part 4 : Who started that VM ?

Events – Part 3 : Auditing VM device changes

In a comment on my Events, Dear Boy, Events – Part 2 post, Sham was wondering if it was possible to find out which device was actually changed on a guest.

Sham was able to find out who did a change, at what time and on which machine, but he also wanted to know what exactly was changed.

Since this is the kind of audit information that I would like to have as well I had a closer look. And luckily the VmReconfiguredEvent object had all the required information in the configSpec property.

Continue reading Events – Part 3 : Auditing VM device changes