VMware VI Toolkit (for Windows) — new Functions

What? Two posts? Well, as previously mentioned, the final 1.0 version of the VMware VI Toolkit (for Windows) came out 25 Jul 2008. I was excited to see that it fixed the issue of connecting to VMware Server 2 RC1 (released at the start of July 2008), where “Get-VIServer” commands failed from the beta 1.0 Toolkit.

So, in looking around at the new install of the VI Toolkit, I inspected the file that the Toolkit shortcut calls on startup, “Initialize-VIToolkitEnvironment.ps1” (found in Scripts). Huh — a few new aliases and a couple of new functions. “Get-VIServer“, “Get-VC“, and “Get-ESX” are all now aliases for the new cmdlet “Connect-VIServer“. The new functions are “New-DatastoreDrive” and “New-VIInventoryDrive“.

As described in the VI Toolkit’s Administrator’s Guide (PDF), these new functions seem quite tasty. For example, to create a new PowerShell PSDrive that corresponds to a given DataStore in your VMware environment, you could issue the commands:

Connect-VIServer virtualcenterserver.domain.com
New-DatastoreDrive "dsDrive" (Get-Datastore daterstore01)

where real names are entered for the VirtualCenter server (or VMware host) and for the Datastore. Now what? Well, you can “cd” (alias for “Set-Location“) into the newly created DatastoreDrive “dsDrive”. Yeah, that’s navigating the Datastore to which you connected — without need of using the Datastore browser in the VI Client, and without need to SSH to a host. Sweet. As the Admin Guide states, “The Datastore Provider (VimDatastore) is designed to provide access to the contents of one or more datastores.”

Then there’s the Inventory Provider (VimInventory): “…designed to expose a raw inventory view of the inventory items from a server. It enables interactive navigation and file-style management of the VMware Infrastructure inventory.” And, this can be achieved by doing something like:

Connect-VIServer virtualcenterserver.domain.com
New-VIInventoryDrive -Name "viInv" -Location (Get-Folder -NoRecursion)

You can then act on the inventory objects with the standard cmdlets. For example:

cd viInv:ha-datacentersomeFoldervm
dir *oldservers01* | Update-Tools

Of course, you would want to insert the proper path from your environment in the “cd” statement.? Or, you could just set your location to the root of the PSDrive and explore the path structure using standard “dir” or “Get-ChildItem” commands.? Yet another way to interact with VMware VI items using the VI Toolkit.

(And, in case you forgot, you can always use “Get-PSDrive” to see what PSDrives you currently have.)

Advertisements

New VMware VI Toolkit 1.0 fixes connectivity to Server 2 RC1

Well, the final 1.0 version of the VMware VI Toolkit (for Windows) came out 25 Jul 2008, without much fanfare. I had been using the 1.0 beta version for a few months, and things seemed good. I used it against ESX 3.0.1 and VirtualCenter 2.0 at work, and against beta versions of VMware Server 2.0 at home.

When VMware Server 2.0 Release Candidate 1 came out, I was quite unhappy that the VI Toolkit seemed to no longer work. I couldn’t even get Get-VIServer to connect to the local web services provided by VMware Server, though it had worked great for the last few months. Issuing the command:

Get-VIServer localhost -Port 8333

yielded nothing but an error. For weeks I tried different steps, from removing the VI Toolkit, to removing the Toolkit and Server, and reinstalling fresh. No dice.

I had pretty much given up, until I saw that v1.0 final of the Toolkit was available. After uninstalling the beta version, and installing the new version, jackpot. The “Get-VIServer” command mentioned above now worked again! Score. You might notice that the command is now an Alias for the new cmdlet “Connect-VIServer“. You might not. There is also a corresponding “Disconnect-VIServer“. Hurray.

Either way, VMware apparently changed something in Server RC1, and the new Toolkit is apparently updated as well to accommodate said change. I searched the web off and on for a couple of weeks. Hopefully this post will save someone some trouble.