VI Toolkit and the PowerShell 2.0 Integrated Script Editor

Finally got a chance to install the PowerShell 2.0 CTP3, and have a look at the Integrated Script Editor (ISE). It has all the basic functionality you would expect from a scripting editor, including a very handy tab completion of cmdlets. It didn’t pick up the VI Toolkit cmdlets straight away for me though, so here’s how you’d enable that if you run into the same issue.

The ISE only picks up snapins that are loaded via one of the ‘AllHosts’ profiles, which is either ‘$pshome\profile.ps1’ (the AllUsers\AllHosts profile) or ‘$home\[My] Documents\WindowsPowerShell\profile.ps1’ (the CurrentUser\AllHosts profile). Until now I have stuck with using the CurrentUser\CurrentHost profile to customise my shell, which is in ‘$home\[My] Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1’. As a result, all the VI Toolkit cmdlets are available in any powershell session, however they aren’t available in the ISE.

So the fix was obviously simple – rename ‘$home\[My] Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1’ to ‘profile.ps1’. For anyone out there who doesn’t load the VI Toolkit with their normal powershell environment, simply add the following line…

add-PSSnapin VMware.VimAutomation.Core

… to $home\[My] Documents\WindowsPowerShell\profile.ps1 and you’re done!

Advertisements

Tags: ,

Leave a Reply

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


%d bloggers like this: