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

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

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

PowerCLI Book Update

As we announced in our post “We’re writing a book!“, Alan and myself started writing a PowerCLI book.

At about the same time Alan got the once-in-a-lifetime oppurtunity to join EMC as a vSpecialist.

Now you don’t become a vSpecialist for free! Alan has been spending a fair amount of time in training, coming up to speed with VCE (VMware/Cisco/EMC) and traveling all over the globe. The little time he was at home, went of course in the first place to his loved ones.

As a consequence, our chapter-writing schedule failed misserably.
So we decided to get some extra help for the book in order to keep our deadline.

And now, for the proverbial “silver lining”, have a look who agreed to help us out:

Glenn Sizemore Jonathan Medd Arnim van Lieshout

Winner of the

Scripting Games 2010

vExpert

PowerShell MVP
vExpert

In other words, the book will now be written by “4 vExperts and a MVP” !

Can’t wait to read it 😉

Script vSphere 4.1 AD Authentication

One of the new features that came with vSphere 4.1 was the ability to use Active Directory Authentication on ESX(i) servers for permissions, console access and ssh access.This is a great feature that you will probably want to activate on all your ESX(i) servers.

Unfortunately this new feature is not available in PowerCLI 4.1. That means you can’t set this up in your configuration scripts through a PowerCLI cmdlet. In most such cases you can fall back on one of the SDK APIs to bypass this lack of a cmdlet. But unfortunately the new “managers”, of which HostActiveDirectoryAuthentication is one, are not available in the VMware.Vim assembly either.

Rob raised this in a recent PowerCLI Community thread. Yasen, one of the PowerCLI Dev Team members, provided a bypass. To make this bypass a bit more accessible, I decided to roll it up in a PowerShell function.

Continue reading Script vSphere 4.1 AD Authentication