How to make an HTML GUI for PowerShell scripts?

Viewed 22405

I have an automation script for making new AD clients and Google mails. I would like to make a Web UI for this (HTML & CSS) so my team can log to this page and create from anywhere thy are.

How can I do it?

Is there a guide for making an HTML page connected to the PowerShell script?

5 Answers

One option (of many) is to have Powershell host your HTML. Use the System.Net.HttpListener web listener, and answers requests based on what you are wanting to provide.

There is an article about building a web server with Powershell:
https://4sysops.com/archives/building-a-web-server-with-powershell/ https://www.powershellgallery.com/packages/HttpListener/1.0.2/Content/HTTPListener.psm1

When you have such low level control of the data scream, you can leverage the power of HTML into powershell.

Now, while this fits your question, this is pretty complicated (any time you have to develop in multiple languages at the same time -- HTML, Powershell, perhaps Javascript, etc), it can get complex in a hurry.

My suggestion is to make sure you really need the app your building to be web based.

If you just wanting GUI (and web is not a requirement) then this task would be far easier using the .NET forms ability of some of the other answers.

The powershell gallery link actually has a functional Powershell web server script in just under 175 lines (plus comments) that was originally written within Microsoft in 2014.

(The Microsoft code, in case it moves URL's, is called HTTPListener.psm1 so it can be found in a web engine search)

Shameless plug, but I've recently published a .NET5-based open source web app you might want to check out called SpecOps. It's intended to allow non-technical users the ability to run powershell scripts via a web-based GUI. You define your scripts and their input parameters in a json config file and it builds the GUI for your users on the fly.

Related