The Series

Edit - I have changed the title of this blog series from AngularJS GUIs with PowerShell to just PowerShell GUI with HTML. I will make a second series though covering AngularJS, how and why you should use it for making PowerShell GUIs but I figured that it needed to be split out.

The Concept

I am going to cover in the next few blog posts a method I have developed for developing user interfaces for PowerShell scripts using HTML. This is not an HTA. This is all built from within PowerShell.

So I decided I wanted to add in a new feature to the PoshProgressBar module. It is always handy to be able to close out of a window but still be able to monitor progress via the notification area, so I decided an icon in the notification tray would be a good next step.

Alright, so just wanted to share some brief notes here on a technique for doing SAPGUI scripting from PowerShell.

It’s not pretty

I’m sure this isn’t the best way to integrate PowerShell and SAP. I’m not an SAP expert but this may help someone in a pinch so I thought I would share.

By default SAP GUI scripts are recorded in VBScript. The very first thing that is usually done is to call GetObject(“SAPGUI”). PowerShell can sorta run GetObject but that has some problems. None of us want to get into reflection. So what’s the trick? The MSScriptControl.ScriptControl in 32-bit PowerShell.

Have you ever used the magical cmdlet called Show-Command? Ever wonder how it knows what type of GUI form object to assign to each particular parameter in your cmdlet? Did you even know it works with any cmdlet?

It is a pretty magical cmdlet. One with which you should play sometime. Today, I am going to show you briefly how to see the same data that is used to generate those GUIs. All you would need to do is determine the specific type (i.e. string, integer, boolean) and map that to a specific form object. for example if a parameter expected a string input you would map that to a simple text input. If it expected a boolean you would map it to a checkbox. Cool, but how would I store that information for my custom cmdlets and how would I access that information? The answers are not as bad as you would think.

So I had an idea the other day. Wouldn’t it be cool if I could run EVERY single possible command combinations for my PoshProgressBar Module?

That would be awesome! Wny would that be so awesome?

  1. Automated testing – To guarantee that every single progress bar combination actually ran as expected
  2. Screenshots – The website has a cool dynamic command builder form to fill out that will generate your PowerShell command. It would be sweet to hit “Preview” and see a screenshot of exactly what that particular progress bar looks like.