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

PowerCLI 4.1 brings the New-VIProperty cmdlet

In the new PowerCLI 4.1 build 264274 there are two new cmdlets, called New-VIProperty and Remove-VIProperty, that deserve your special attention.

The New-VIProperty cmdlet allows you to add a new properties to any PowerCLI object (InventoryItem, HostSystem, VirtualMachine…). And it’s up to you to define what the value of this new property will !

The Remove-VIProperty cmdlet allows you to remove such a new property.

These new cmdlets, combined with the new Extension property, will change several of the well established ways that you use in your PowerCLI scripts. And besides adding a lot of flexibility, the extension property will make your scripts considerably faster (if used wisely).

Continue reading PowerCLI 4.1 brings the New-VIProperty cmdlet

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’

Events – Part 7 : Working with extended events – Update Manager

As I already mentioned in my previous post, Events – Part 6 : Working with extended events – Converter, another
add-on that produces extended events, is the Update Manager.

With the recent introduction of the vCenter Update Manager PowerCLI snapin, it is now fairly easy to automate all aspects of patch and update management in your vSphere environment. And with the help of the extended events produced by Update Manager, you can easily produce reports. This post shows one way of doing this.

Continue reading Events – Part 7 : Working with extended events – Update Manager

Events – Part 6 : Working with extended events – Converter

In a previous post, called Events, Dear Boy, Events – Part 2, I mentioned that some tools/add-ons use a special event type called ExtendedEvent. Two classic examples are the Converter and the Update Manager. If you want to compile a report for any these tools it’s important to understand what is available in the extended events they produce.

If you want to know if there are any other tools/add-ons in your vSphere environment that produce extended events, then you can use the first script from the Events, Dear Boy, Events – Part 2 post to get a complete list of all available extended events.

In this post I’ll show how to use the Converter extended events.

Continue reading Events – Part 6 : Working with extended events – Converter

Beyond Export-Csv: Export-Xls

Warning: this post has no “virtual” content !

This time I post a function that allows you to export your data to a “real” spreadsheet (XLS format) instead of a CSV file.

The reason for posting this function was a series of threads in the PowerCLI Community by Suresh. Over several threads he has been collecting scripts that create various reports on his vSphere environment. Ultimately he wanted to have a spreadsheet where each report would be stored on a worksheet.

PowerShell has the very handy Export-Csv cmdlet to create CSV files but afaik nothing for creating XLS files 🙁

Continue reading Beyond Export-Csv: Export-Xls

NX/XD flag setting report

Michael asked if it was possible to produce a report that showed the NX/XD flag setting for all the guests.

Piece of cake I thought, but it turned out to be a bit more complex than that. If you don’t set the NX/XD flag (expose or hide) explicitly on the guest, the hyper-visor will use a default that is defined per OS you can have on the guest.

In the end I think I came up with a script that seems to handle all the different possibilities I encountered.

Continue reading NX/XD flag setting report