How to make an HTML GUI for PowerShell scripts? How to make an HTML GUI for PowerShell scripts? powershell powershell

How to make an HTML GUI for PowerShell scripts?


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.


You use HTML GUIs (HTA) for VBScript and/or JavaScript. For PowerShell you use Windows Forms.

Add-Type -AssemblyName System.Windows.Forms | Out-Null$form = New-Object Windows.Forms.Form$form.AutoSize = $true$form.AutoSizeMode = 'GrowAndShrink'$form.Text = 'Window Title'$label = New-Object Windows.Forms.Label$label.Text = 'some text'$label.AutoSize = $true$form.Controls.Add($label)$form.ShowDialog()