3

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?

1
  • Pick a server side scripting language of your choice. They all support some sort of exec() command to execute scripts on the command line. Commented Mar 16, 2016 at 12:19

6 Answers 6

2

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)

1

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.

0

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()
8
  • This would only work after invoking the script. Not as an interface to invoke the scripts in the first place. Commented Mar 16, 2016 at 12:18
  • True, but inconsequential. You can easily build authentication into the script, and make it available via a common share. Commented Mar 20, 2016 at 10:13
  • 1
    The question was how to use Powershell as a backend for a web client. What is shown here is how to make a Powershell GUI. This misses the biggest point of the request, that of being HTML based.
    – user2883951
    Commented Mar 18, 2019 at 17:38
  • @Jean-ClaudeD. There is no need for using HTML when you're making a GUI for PowerShell scripts because the GUI can be embedded in the script. That way it can be run on any administrative client rather than having to set up web server running a web GUI that in turn runs a PowerShell script. Commented Mar 18, 2019 at 17:47
  • 1
    @Ansgar Wiechers -- Again, you've missed the question is my point. The question was not "How to make a GUI for PowerShell scripts?". It was "How to make an HTML GUI for PowerShell scripts?". We don't know what possible limits the OP who asked the question has. It may be, for some reason, it has to be in HTML (maybe it's part of an existing web site).
    – user2883951
    Commented Mar 21, 2019 at 15:15
0

Easiest might be to use a package like Jenkins that supplies a front end and has auth plugins already and can run powershell as well.

https://jenkins-ci.org/

There is a plugin for running powershell. https://wiki.jenkins-ci.org/display/JENKINS/PowerShell+Plugin

You can even tie it to Active Directory if you need. https://wiki.jenkins-ci.org/display/JENKINS/Active+Directory+plugin

0

You can automatically generate a web front-end for PowerShell scripts using System Frontier. No HTML or server-side programming needed. You just create custom fields and assign them to command-line parameters.

You also get the benefits of having an access control layer in front of the scripts so non-admins can safely run the scripts with admin rights. The script output is also logged for auditing and data mining.

0

There is a Module called Pode and Pode.Web. Powerful Webserver based on Powershell and you can embed your Powershell Commands more informations you can find herePode and here Pode.Web

2
  • any affiliation? /help/promotion also, please show how to use it to solve the problem in the question.
    – starball
    Commented Apr 9 at 8:50
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – n0nick
    Commented Apr 11 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.