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.)


Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s