PowerCLI Series – PowerActions

Some time ago, I did a PowerCLI Series.  There was the getting started in Part 1, followed by Part 2, Part 3, and in Part 4 we looked at getting vCheck working.  That was updated yesterday BTW. After recently playing with some very cool stuff, I realized I needed to add anther chapter to my PowerCLI Series.

I recently got PowerActions working in my lab.  It means that you can – from within the vSphere Web Client, and while working on a Mac, execute PowerCLI scripts.  It has both a private, and shared script repository so that makes it pretty easy. So I think everyone almost should have this functionality so it is now part of my PowerCLI Series.

Making it work

You can find out how in this article. Basically the steps are:

  • Don’t use PowerCLI 6.3 R1 – I used 6.0 R2 with no issues.
  • Use the software from here, v1.5 of PowerActions.
  • Use the info from here to install, but don’t worry about the SSO stuff, as I think most will not need it.
  • Be aware that you likely will have trouble with the MSI install and the solution is here if you need it.
  • I had to restart when things were done on my VM where PowerCLI and PowerActions were installed, and restart my vSphere Web Client browser session too.

What does it look like?

The first thing you will notice is likely the view from Home.


But, if you access the PowerCLI Console you can do this.


I typed in get-vm at the bottom of the screen and the result were displayed above in the Console window.

Exploiting the functionality

I am doing this section as this is a little different then scripting normally.  At least for me. If we change to PowerCLI Scripts are we will see something like below.


Notice at the top you can see both My scripts, and Shared scripts? This means it is easy to have your own scripts or use someone else’s scripts.  Handy.

Creating our first script

I want a script to disable SSH in my hosts.  I have one I shared with you in this article. Nice script that works good, but is not appropriate for us in PowerActions. BTW, that is because it has a lot of ‘extra’ info in it that PowerActions doesn’t need – like the prompt to name your vCenter.

So we use the small icon under My scripts and we get – surprise – a wizard.


Our script – disabling SSH is going to be for all the hosts in a cluster.  So Target type as seen above is good.


In the next screen of the wizard we see the typical name and description fields.  But we also see how the output of the script will be formatted.  If we are pulling info out of the virtual infrastructure and need it easily read that means Report, but if we are making changes like we are by disable of SSH then Action is what we need.


We can see above that there is a top part of the script seen, which is there by default, and then the Get-Cluster script that I added.

BTW, what I added is:

Get-Cluster | Get-VMHost | ForEach {Stop-VMHostService -HostService ($_ | Get-VMHostService | Where {$_.Key -eq “TSM-SSH”}) -Confirm:$FALSE}

When you move to the next screen you will see a summary.


You now – or rather, once you hit Finish, have a script.

You can see in the screenshot below that my hosts have SSH enabled.


So if you put the cursor on the cluster, we can test our script out.


We can see we can create, or execute a script now.  If we select Execute Script, we will see something like the following.


I am going to select SSH_Off, and follow that with OK, as that is what I want to do.

BTW, if you select a host, and try to execute this script it will not work.  Will look into that too.

We will see a blue box pop up and before you know it you will see the following.


If I check my hosts, I should see no SSH running.


Pretty cool?  I think quite handy, and remember I am doing this all on a Mac using Chrome.

Other Scripts?

Enable SSH

Get-Cluster | Get-VMHost | ForEach {Start-VMHostService -HostService ($_ | Get-VMHostService | Where {$_.Key -eq “TSM-SSH”}) -Confirm:$FALSE}

VMs created during the last 14 days

Get-VIEvent -maxsamples 10000 -Start (Get-Date).AddDays(–14) | where {$_.Gettype().Name-eq”VmCreatedEvent” -or $_.Gettype().Name-eq”VmBeingClonedEvent” -or $_.Gettype().Name-eq”VmBeingDeployedEvent”} |Sort CreatedTime -Descending|Select CreatedTime, UserName,FullformattedMessage

I should mention that I got this script from Brian’s article on PowerActions, and I saw the same on on Alan’s site, but it did not quite work for me.  It found stuff I created today, but not stuff I created 5 days ago.

Last 10 VMs created, cloned, or imported

Get-VIEvent -maxsamples 10000 |where {$_.Gettype().Name-eq “VmCreatedEvent” -or $_.Gettype().Name-eq “VmBeingClonedEvent” -or $_.Gettype().Name-eq “VmBeingDeployedEvent”} |Sort CreatedTime -Descending |Select CreatedTime, UserName,FullformattedMessage -First 10

Again, I have to admit that this is only showing from today, and not the last 10 VMs created, cloned or imported.  Again got it from Alan’s site so I have to believe it is a perfect script and that something else is odd. I tested this outside of PowerActions and it displayed only one VM – deployed today, just like I saw in PowerActions so something odd.  There should have been two.

Last 5 deleted VMs

Get-VIEvent -maxsamples 10000 | where {$_.Gettype().Name-eq “VmRemovedEvent”} | Sort CreatedTime -Descending |Select CreatedTime, UserName, FullformattedMessage -First 19

This iis a good script.  It should show the last 5 deleted VMs.


We have another PowerCLI Series article complete.  We got PowerActions working, and saw how to create and execute scripts with it.  I did show some scripts that are not quite working right now, and when I figure things out will update them, this article or whatever is necessary. Don’t forget that I created and executed these scripts while working in the vSphere Web Client running in Chrome on a Mac!

Remember you can follow the articles in this series using this tag.

Thanks for reading,


=== END ===

3 thoughts on “PowerCLI Series – PowerActions

  1. vCheck is working fine for me with PowerCLI 6.3 R1 including sending the report as email! Now I will take a look at the Poweractions next…

    1. Very glad to hear it is working with you. Are use using the latest vCheck – 6.22? As I was and it has a bug that will in fact limit the sending of email – in a new install that is.

      Also, I am curious about your powerCLI install. Other people had the same issues as I but they were all – I think – new installs of PowerCLI 6.3 R1. I wonder if you were an upgrade? That might make a difference.


      1. vCheck is latest version 6.23-alpha-3!
        And if I remember correct, PowerCLI was upgraded from 6.x to 6.3 to 6.3 R1!

Leave a Reply