Home > Blogs > VMware PowerCLI Blog


Running PowerShell from VI Client with icomasoft PowerScripter

When I was chatting with Glenn last night during the live PowerScripting Podcast he asked when he was going to be able to run PowerShell scripts from inside of VI Client. I asked if he had checked out icomasoft as they have a really nice tool called VI PowerScripter for doing just that.

I had used their Beta 1 plugin, but since they have a Beta 2 now I downloaded it and wanted to give an account of my experiences with Beta 2. I think you’ll see how easy it is to get started and get to the point where you can plug in your own scripts. In this post I want to talk about one of the useful things you can do with icomasoft’s tool.

Snapshots: The silent datastore killer.

Have you ever had a snapshot fill up your datastore because you forgot about it? One of the drawbacks of snapshots is that they get bigger and bigger as you VM writes data. If left unchecked they will keep getting bigger until they finally fill your datastore, making it impossible to do just about anything. It’s happened to me more than once, and from the people I’ve talked to I’m certainly not the only one.

Step 1, of course is to download PowerScripter and run the installer on the same computer where you run VI Client. After you do that, PowerScripter will show up under the Plugins menu.

1_3

2_2

If you don’t see PowerScripter, make sure it’s enabled by clicking Manage Plugins…

With PowerScripter you define you own PowerShell scripts that run against hosts or against individual VMs. Let’s go through the process of adding some custom scripts.

3

When you select Script Repository you’ll find yourself in a folder with two subfolders, named HostScripts and VmScripts. To define custom ESX host scripts, place a file inside HostScripts. To define a custom VM script, place it in VmScripts.

4

When you install, there are no pre-canned VM scripts. You can find samples at icomasoft’s website, but for this example I’ll just add a few of my own.

5

I added two scripts, one called DeleteAllSnapshot.ps1, one called SnapshotReport.ps1.

6

Below is the text of the scripts:7

8

Now let’s head back to the VI Client to start running scripts. Unfortunately the Beta of PowerScripter has a small feature that hopefully gets fixed soon, you’ll need to restart the client. Update: actually to have the scripts show up you can disable then re-enable the PowerScripter plug-in under the Plugins menu.9

After we restart we’re ready to run our scripts.10

This is most useful when you multi-select systems, as show in this screen.11

The report shows us the snapshot’s name, description, parent VM, and, most importantly I think, when the snapshot was made. If a snapshot is too old, chances are it needs to get deleted.12

If you find that a VM has snapshots that need to disappear, you can either remove individual snapshots from the VI Client’s snapshot manager or you can remove them all at once through PowerScripter. Even better, if you need to remove all snapshots on a group of VMs, just multi-select them and you’re nearly done.

Support resources for icomasoft

PowerScripter is just getting started, but icomasoft has a forum where you can go to share ideas and get samples, you should stop by and say hi. Also, even though PowerScripter doesn’t come with any scripts out-of-the-box, there are several sample scripts in their manual that you can drop in and start using. One really useful one is their storage rescan script which allows you rescan all storage across all your hosts with just one click, a huge time saver if you’re still doing it the old-fashioned way.

2 thoughts on “Running PowerShell from VI Client with icomasoft PowerScripter

  1. Dennis Zimmer - icomasoft

    thanks for that nice article about our tool!
    But I´ve got three things to say:
    1) You don´t have to restart the VI client – it´s enough to deactivate and active the plugin (so two clicks within a second)
    2) You can find some Sample scipts at the download section here: http://www.icomasoft.com/products/vi-powerscripter.html
    More will follow with the final release
    3) with beta 2 we fully integrate the PowerGUI (of course the PowerGUI must be installed on the system). So you can directly edit/debug the script – just hold shift while clicking the script within the PowerScripter context menu

    Reply
  2. Brian Butler

    Icomasoft’s PowerScripter has been acquired by Devfarm Software in the Summer of 2011, and has been renamed to PowerVI
    It can be found here: http://powerwf.com/products/powerscripter.aspx.
    Press Release Here:
    http://www.prweb.com/releases/PowerVI-PowerScripter/NewReleaseAvailable/prweb8758291.htm
    We are very excited about the integration PowerScripter technology with PowerWF products. Devfarm has tightly integrated both with PowerSE PowerShell Script Editor & plus PowerWF – Visual PowerShell (Workflow & PowerShell combined). The integration gives administrators instant ROI, with the wide array of scripts that are included in the box. The integration of Devfarms PowerShell automation tools make easy to extend & customize vSphere to met your needs.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>