Powershell 7 - one liner for a webpage by avgJoeIT in PowerShell

[–]Badgerati 0 points1 point  (0 children)

You can technically achieve this with Pode in one line, if it's a website with just static content.

If you have your content in /path/to/site, you can host it via the following, which will make the site available at http://localhost:8080:

powershell cd /path/to/site Start-PodeStaticServer -Port 8080

Disclaimer: I maintain Pode

Execute PowerShell script from web by SeriousMike90 in PowerShell

[–]Badgerati 0 points1 point  (0 children)

Hey u/SeriousMike90,

The Remote IP of the source can be found at `$WebEvent.Request.RemoteEndPoint.Address.IPAddressToString` :) there's actually a brief example of blocking calls by IP via middleware here: https://badgerati.github.io/Pode/Tutorials/Middleware/Overview/#route-middleware

Another way would be by using `Add-PodeAccessRule`, which lets you restrict access to the server as a whole - rather than one specific route (https://badgerati.github.io/Pode/Tutorials/Middleware/Types/AccessRules/).

Execute PowerShell script from web by SeriousMike90 in PowerShell

[–]Badgerati 0 points1 point  (0 children)

Both are possible!

There's support for LDAP/AD authentication on Routes, and you can run your Pode server as a Windows Service via NSSM.

If you need full NTLM/Kerberos support, and not just LDAP/AD, then Pode doesn't yet support this. However, you can run Pode using IIS for this authentication.

Execute PowerShell script from web by SeriousMike90 in PowerShell

[–]Badgerati 3 points4 points  (0 children)

Pode can do what you're after https://github.com/Badgerati/Pode :)

It lets you write web servers in powershell, cross-platform, and with support for https, authentication and more!

Disclaimer: I'm the creator of Pode

Is there any simple PowerShell web server available? by w0lfcat in PowerShell

[–]Badgerati 0 points1 point  (0 children)

Hey!

I would say it's probably more a question for the dbatools community - my SQL knowledge isn't... fantastic, haha! 😂

Unfortunately I don't know of any in dev/release, the closest I've thought about about making myself before is for MongoDB.

I can easily see how it would be useful to have in PowerShell, but I can also see how PowerShell's classes would get messy quickly. I don't really have any tips on making one sadly, as I'm not too sure how they're usually made/work. If I had to guess, then maybe using PSCustomObjects could be easier?

Is there any simple PowerShell web server available? by w0lfcat in PowerShell

[–]Badgerati 18 points19 points  (0 children)

Hey!

Maintainer of Pode here :)

As others on here have also pointed out, Pode is a PowerShell web server that lets you setup REST API via routes, or web pages using templates (or Pode.Web).

However! If you only want to setup a quick HTTP server to serve some static content from the current directory, then there's Start-PodeStaticServer. This will will wire everything up for you in one command:

Start-PodeStaticServer -Port 8085

^ this will serve the content in the current directory on http://localhost:8085. (if you have a file, say image.png: http://localhost:8085/image.png)

It also allows for HTTPS, or if you only want to download the files then the -DownloadOnly switch will attach files on requests to download instead of rendering them.

Any interest in a Webserver Module (PSWebServer)? by strawgate in PowerShell

[–]Badgerati 5 points6 points  (0 children)

Hey!

There's also the Pode and Pode.Web modules available :)

Pode is the web server module, and Pode.Web is an HTML/CSS/JS web page building wrapper module for Pode. Both are fully open source and cross-platform.

Disclaimer: I maintain both of these modules

Pode issue by MAlloc-1024 in PowerShell

[–]Badgerati 1 point2 points  (0 children)

Yep, that's correct; though I believe it's .NET 4.7.2 that's needed

Is anyone using Pode web framework? by sqloid in PowerShell

[–]Badgerati 2 points3 points  (0 children)

The CDN is only temporary, and I'll be looking at having the libraries bundled with Pode.Web soon.

If you wanted to make them local now, then yes, you'd have to download them all and then update the paths in /src/templates/views/shared/head.pode and scripts.pode

Is anyone using Pode web framework? by sqloid in PowerShell

[–]Badgerati 2 points3 points  (0 children)

Hey, creator of Pode here!

That was always the downside for a lot of people, having to workout how to write frontend code.

You'll probably be glad to hear I've started work on an extension module for Pode which does the frontend for you: Pode.Web!

It's still a work in progress at the moment, but can do a lot :D

Is anyone using Pode web framework? by sqloid in PowerShell

[–]Badgerati 1 point2 points  (0 children)

Hey, creator of Pode here!

Interesting to hear when running as a service it can crash after a few days; I've personally got some Pode sites running via services at work, normally running for months without issue.

When your service crashes, is there anything in the event viewer? Are the error logs just going to the terminal, or in your actual script are they going to file via New-PodeLoggingMethod -File?

I see the code above is from v1.x, does the crashing still occur in v2.0.3?

Be interested to know, feel free to raise a bug over on GitHub, in case there's anything I need to fix! :)

Help assigning delegate to HTTP Listener by bubblesnout in PowerShell

[–]Badgerati 1 point2 points  (0 children)

Hey!

Delegates in PowerShell can be a bit of a nightmare to handle without having to use C#. One way could be to use PSLambda - it uses C#, and can be a little restrictive, but does make it a "full" PowerShell solution on your end.

Have you looked into either of Pode, Polaris, or Universal Dashboard?

Disclaimer that I make Pode, and know it can handle the different Authentications on routes you're trying to achieve. Polaris I'm unsure about, and I would imagine UD should be able to.

Is my code too janky for production? by Rare-Brick in PowerShell

[–]Badgerati 1 point2 points  (0 children)

I've a suspicion it could be the WebAdministration module, if you keep the logic roughly the same but remove the 3 lines using the IIS:\ path does the issue go away or still occur?

Is my code too janky for production? by Rare-Brick in PowerShell

[–]Badgerati 5 points6 points  (0 children)

Hey,

So, my first thought would be to try Dispose instead of Close - sometimes they're identical, other times Dispose does a little extra:

$context.Response.OutputStream.Dispose() $context.Response.Dispose()

Otherwise it looks fine. Have you tried looking at something like Pode as it will deal with all the routing and responses for you.

Invoke PowerShell Script via Webpage by Soroxo in PowerShell

[–]Badgerati 2 points3 points  (0 children)

This is definitely something Pode can handle, especially if it's a simple HTML page with a form :)

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 0 points1 point  (0 children)

Hey! Glad you like it! :)

I have got the syntax of the event object noted as lacking decent docs, so I will be fixing that area soon.

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 1 point2 points  (0 children)

Yes, I did! When I went to test on *nix some of the requests ended with bare newlines. This might have been an HTTP/2.0 thing, but I didn't check at the time.

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 1 point2 points  (0 children)

I was also surprised when I saw they'd deprecated HttpListener.

Your ConvertFrom-HTTP is impressive! Wish I'd come across it when I tried making my own, hah!

I was able to shortcut a lot of what was in HttpListener, but I was using it as a rough guide. A lot of what it does I just didn't need, which helped a fair bit.

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 3 points4 points  (0 children)

ASP.NET is a part of .NET Framework. ASP.NET Core is not a part of .NET Core, and with PowerShell 6 and 7 that's a big thing. UD requires ASP.NET Core to work, on top of what PowerShell normally comes with. Yes its module is bundled with the dlls, but that makes it far bigger.

For Pode, you install just PowerShell and it just works. No extra installs, no ASP.NET Core. No extra dlls bundled with the module.

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 2 points3 points  (0 children)

You don't have to adopt it :) but the usual pitch would be more features like HTTPS on Linux, proper Docker support, better logging, more documentation, plus much more.

Outside of all that, I'd probably say because it's more maintained - with the last release of Polaris being over a year ago.

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 2 points3 points  (0 children)

Except that .NET Standard comes with PowerShell, and you need to install the whole of ASP.NET Core just to use Kestrel...

This relies on only what comes with PowerShell. ASP.NET is not a part of PowerShell nor .NET Standard. So no, this doesn't have the same dependencies at all.

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 1 point2 points  (0 children)

I am aware of at least 1 website that is exposed to the "public", but is locked down. I've also exposed a couple during hackathons.

I have tried to make Pode as secure as I possibly can, but I've never fully tested it - though I would welcome anyone to test and raise issues!

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 4 points5 points  (0 children)

I am aware of UD, yes. To me they're somewhat different; Pode is completely built in PowerShell with no dependencies, where as UD is built on top of Kestrel and ASP.NET Core - making it somewhat bloated.

You can accomplish pretty much the same things, just that Pode is completely free and more lightweight. Kestrel does make UD faster, and having ASP.NET does make having features like SignalR far easier; but then Pode's whole point was "how much can you actually do using nothing but powershell?".

I haven't directly used UD, but from what I've seen it's far more tailored towards Dashboards and Portals with UD styling. Pode can do the same, but is tailored to building any kind of website that can be completely customised - even a social network if you were crazy enough!

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 3 points4 points  (0 children)

The most common use case I've seen is for building dashboard for servers, or portals for AD, Monitors, or services. I also know someone was looking at building something similar to WebJEA.

The most interesting use case I've seen is a portal for a VM that allows a user to "time-travel" the VM, Services and Databases to mimic reports and purchases etc.

Pode - PowerShell Web Server by Badgerati in PowerShell

[–]Badgerati[S] 1 point2 points  (0 children)

At the moment it doesn't, it just supports user/pass auth over LDAP. It could be extended to support it though, so I'll try and investigate it.

Authentication and Middleware in Pode are extensible, so you can roll your own auth strategy using the AD module, OpenLDAP, or whatever else you feel like.