Two things I enjoy in technology: PowerShell and web development. I have written before about bringing these two things together by using PowerShell to generate json data. Gumper, as I will explain, makes it easier for sysadmins and web developers to take advantage of this technique by providing an API to run scripts on-demand and get json as output.
Over the past couple years, I have been working on an internal support tool that launches PowerShell scripts through a web-based GUI. While development has continued on this project, it became clear that its ability to run PowerShell scripts needed to be separated from the application itself (MVC, right?). Gumper is the solution to that need. Gumper, licensed under the MIT license, maintains a registry of local scripts (currently Bash and PowerShell) on a server, which can be run using their unique ID (generated by Gumper) and an auth key provided via GET. Gumper will also accept arguments for the script.
Why is this important for sysadmins and web/front-end developers? I have seen a lot of sysadmins write great scripts and web developers create really useful tools. But, very rarely have I seen a web developer have both the expertise and access to integrate a sysadmin’s script output into a handy tool. Gumper makes this possible with minimal work on either end: sysadmins already know how to write scripts and web developers already know how to work with an API and parse json. And, it just makes the whole process easier. Help Desk needs to see which user accounts are disabled? Easy. Write a script and throw it into Gumper. CFO wants to know how many pages a department is printing? Gumper! Well… at least to get the results. Then, something else should actually parse it into an understandable format (coming soon…).
The important thing to know is: It’s easy to make your existing scripts work with Gumper. You can read more on the project wiki, but if your scripts are written in PowerShell, it’s insanely simple. All you need to do is add the following output to your script (keep in mind, this doesn’t work with interactive scripts that use a lot of read-hosts; that should be built into an interface):
... $json = $object | convertto-json#Where $object represent the results you want to return Write-Host "[[OUTPUT]]" $json Write-Host "[[/OUTPUT]]"
Gumper will return only the output between the two OUTPUT tags. Now, add your script to Gumper’s registry (you cannot upload scripts via Gumper, so they must already exist on the server) and you can get the results using something like this:
Your response might look something like this:
Note the authKey used in the above example. That is the default and you should change it before making Gumper available! To change it, just open keys.psrconfig and change…
… to something unique.
So, those are the basics, but you should really checkout the README and wiki on Bitbucket if you are interested in using Gumper. It is still very new, so please allow for some glitches and feel free to submit feedback, fork the project, etc. It may not be exciting on its own, but paired with some front-end development (hopefully, my next project to be released), it has some important implications.