Public web site with PowerShell back-end

Hi,

I have an idea for a web page and was wondering if it is possible to use a PowerShell back-end for the site? for example, if a user clicks a link, some processing happens on the server using PowerShell then the output is displayed on the web site? Is this even possible? Would I need to find an ASP.NET hosting service for this?

Thanks

Lots of folks do this so definitely possible. I’d look at Universal Dashboard or Polaris, both modules you can use to spin up a web server

1 Like

It is most likely possible, but ASP.NET is typically C# or VB.NET. Powershell is basically a wrapper, written in C# to interface with .NET. Server-Side code would run in C#\VB.NET, so you can run things directly in C#\VB.NET rather than use Powershell. If you are taking a Powershell script that is text or upload and executing that, that is also possible to execute scripts via C# or VB.NET.

How to execute PowerShell script or cmdlets from C# code? · GitHub

Keep in mind that running something in ASP.NET is running in IIS and security controls will normally not like a web service trying to execute things locally on a server. Then you get into permissions, user elevation, running the script as or other things it will get complicated very quickly. Most of the time you would have an agent or service running on the server separately from the website to execute that code and return a result via an API.

I’ve see solutions where they have Powershell containers on the website and can execute code via agent proxies for RPA. It is possible, but there are many security issues to plan for depending on what you are trying to accomplish.

I would not suggest to have PowerShell backend for a webservice. But there are solutions with PowerShell too.
Have a look at PowerShell/Polaris: A cross-platform, minimalist web framework for PowerShell (github.com)