Hitchhiker’s Guide to Get-EsxTop – Part 1

The PowerCLI Dev Team gave us an early XMas present yesterday. They released PowerCLI 4.1.1 build 332441 or PowerCLI 4.1 Update 1 as it is called in the Release Notes.

As usual there is a nice collection of new cmdlets and improvements on existing cmdlets in this new PowerCLI 4.1.1 build. Two of the new cmdlets that jump out for me are the Get-EsxCli and the Get-EsxTop cmdlets.

Although both cmdlets are still marked as ‘experimental’, they both open up a complete new area for automation. In this post I’ll have a closer look at the Get-EsxTop cmdlet and what you can do with it.

Continue reading Hitchhiker’s Guide to Get-EsxTop – Part 1

Get your tasklog here!

It happens quite often that you launch a PowerCLI cmdlet or a call to a SDK method or a script and that you get a rather cryptic message that something went wrong. One source of information to find out what went wrong are the vCenter’s vpxd log or the ESX(i) server’s hostd log.

But these logs are flooded with messages and it’s often quite hard to find the messages that relate to your task.

When running against a vCenter Server you can set the vCenter’s Logging Options to “Verbose” or “Trivia“. That produces more information in the logs but that often also makes it harder to find/extract the information that belongs to your task. And who has never forgotten to set the the Logging Options back to their original state when done with debugging ?

To make life a bit easier, I wrote a function that automates the above steps. I expanded on a function that I was using privately, and made it more general. This function allows you to retrieve the log entries for one specific or all recent task. The function also allows you to pass a cmdlet, or even a complete script, run the script in an elevated Logging Options mode and returns the task-related log entries.

Continue reading Get your tasklog here!

Get the folderpath

A useful property that is obviously missing from the Get-Folder cmdlet, is the path of the folder. In the PowerCLI Community there are regularly threads that ask for this kind of information. Most of the time it concerns scripts to export/import folder structures or scripts to migrate vCenters.

Another property that is obviously missing, is the indication if a specific folder is a so-called “blue” or “yellow” folder.

To solve this problem once and for all, I wrote this short function, called Get-FolderPath, that will return you both of these properties.

Continue reading Get the folderpath

Automate SIOC

With vSphere 4.1 came 150+ new features. One of these is called Storage IO Control or SIOC.And it has been a very popular subject in the last weeks. Just a small selection of blog posts on the subject:

The only thing missing was a way to automate everything surrounding SIOC. And so I decided to write a couple of functions to fill that gap.

Continue reading Automate SIOC

Runtime Name via Extensiondata and New-VIProperty

One of the demos we did in our VMworld 2010 US and Europe sessions, showed the use of the new Extensiondata property and of the new New-VIProperty cmdlet. Both features were introduced with PowerCLI 4.1. In my PowerCLI 4.1 brings the New-VIProperty cmdlet post I already showed the interesting possibilities this new cmdlet offers.

On my return from VMworld Europe there was a new thread in the PowerCLI Community that asked how one could get at the Runtime Name property as it is shown in the vSphere Client. The Get-ScsiLun and Get-ScsiLunPath cmdlets unfortunately do not return that property. So I guessed it was time to show once more the strength of the New-VIProperty cmdlet.

Continue reading Runtime Name via Extensiondata and New-VIProperty

Nearly real time monitoring

The VMTN Communities have always been a useful source of inspiration for writing scripts. This week, for example, there was an intriguing question raised in the Onyx Community. The user wanted to know if it was possible to monitor changes in the vSphere environment in real time.

As far as I know there is no API in the vSphere SDK to do real time monitoring. But the EventHistoryCollector can deliver something that I prefer to call nearly real time monitoring. The following script is a very basic function, written primarily to show that this principle of nearly real time monitoring works. The function displays some selected properties of each event it sees.
Continue reading Nearly real time monitoring

Finding Thin disks

Last Sunday there appeared an interesting thread in the VMTN PowerCLI Community where one the questions was how to find all ‘Thin‘ virtual disks without passing via a virtual machine. The reason for this question was that most of the user’s virtual machines in Lab Manager are not registered on the vCenter Server.

My first idea was to use ‘Get-Datastore | Get-Harddisk‘ and then use the Extensiondata property to query the thinProvisioned property. Something like Arne did in his PowerCLI: Virtual Machine Disk (VMDK) info post. But that, unfortunately, doesn’t work since the Extensiondata property is $null in this case.

Continue reading Finding Thin disks

Taking the new Onyx 2.0 for a spin

One of the announcements during VMworld 2010 in San Francisco that perhaps got a bit obscured by the other “big” announcements, was the release of Onyx 2.0. For those of you that hadn’t heard of Project Onyx before, this nifty little tool captures all SOAP traffic that is passed between your vSphere client or PowerCLI session and the vCenter or ESX(i) server to which you are connected.

And that’s not all, the Onyx program will translate the captured SOAP traffic into PowerShell code. This allows you to see which vSphere APIs are used and how parameter objects for these methods are constructed.

Update September 16th 2010: the Onyx Development Team has just released a new build (2.0.3910.32223) that fixes some issues when using Onyx with the PowerCLI client.  Congratulations to the Onyx Development Team for this quick resolution of the problem !

Continue reading Taking the new Onyx 2.0 for a spin

Using the ThinApp SDK from PowerShell

On August 19th 2010 the long awaited ThinApp SDK became available.It allows you to programmatically interact with your ThinApp packages.  The SDK package is foreseen to be used with Visual Studio, as can be deduced from the  included merge module called ThinAppSDK.msm. The samples that come with the SDK unfortunately only show the use of the SDK with C++ and VBScript. But with a bit of fiddling it’s quite easy to use the APIs from your PowerShell environment.

This post will show you:

  • how to set up the SDK for use from PowerShell
  • some usage examples from PowerShell.

Continue reading Using the ThinApp SDK from PowerShell

On parents and nested properties

In a recent post on the vSphere PowerCLI Blog, called New Nested Properties for Navigating to Parent Objects in PowerCLI 4.1, some new features were introduced.

In PowerCLI 4.1 some objects now have, besides the ParentId property, the actual parent object itself. This will take quite some complexity out of several scripts. This is definitely a good improvement.

The 2nd novelty in that post were nested properties. Some SDK object properties are now mapped directly in the PowerCLI object. For example the VMHost object now holds the StorageInfo and NetworkInfo properties besides some others. And what is even better, there is hardly any performance impact since the values will only be loaded the first time you access the properties (similar to the ExtensionData property).

Continue reading On parents and nested properties