| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Powershell WebServer is a module that starts a webserver (without the need for IIS). Powershell command execution, script execution, upload, download and other functions are implemented.
Powershell WebServer is is primarily intended as an example or base for own development. No multi threading, only one client at a time!
See Script Center version: Powershell Webserver.
Author: Markus Scholtes
Module version: 1.0.7 / 2024-02-03
Script version: 1.6 / 2024-01-31
Install with
Install-Module WebServeror download manually here
Now also on Powershell Gallery as part of the SysAdminsFriends module, see here or install with
Install-Module SysAdminsFriendsProject page on github is here.
The .Net class System.Net.HttpListener delivers a basic web service without the need to install a webserver (IIS) role. Since we can use it in C#, we can do it with powershell too (and even without pain).
There are several examples of powershell webservers in the internet, but for me it seems they all have the same origin. Thank you, original coder, whoever you are! My impulse to write a powershell webserver was a short but very impressing example on powershell.com (that unfortunately is no longer online).
The module WebServer implements a webserver with the following functions:
The webserver responds to GET methods only except the POST upload and download functionalities (implementing this really did hurt).
Other functions can be implemented very easily.
If you give it a try, see remarks below by all means.
Start webserver with binding to http://localhost:8080/:
Start-WebserverStart webserver with binding to all IP addresses of the system and port 8080. Administrative rights are necessary:
Start-Webserver "http://+:8080/"Start powershell webserver as scheduled task as user local system every time the computer starts:
schtasks.exe /Create /TN "Powershell Webserver" /TR "powershell -Command \"Start-Webserver http://+:8080/\"" /SC ONSTART /RU SYSTEM /RL HIGHEST /FYou can start the webserver task manually with
schtasks.exe /Run /TN "Powershell Webserver"Delete the webserver task with
schtasks.exe /Delete /TN "Powershell Webserver"(Scheduled tasks are always running with low priority, so some functions might be slow)
You can embed powershell code in html files with psp files ("Powershell Server Pages"). Psp files are html files in which the switch code <% toggles to powershell code and %> toggles back to html. Parameters can be handed per GET or POST.
You may have to configure a firewall exception to allow access to the chosen port, e.g. with:
netsh advfirewall firewall add rule name="Powershell Webserver" dir=in action=allow protocol=TCP localport=8080After stopping the webserver you should remove the rule, e.g.:
netsh advfirewall firewall delete rule name="Powershell Webserver"You can also let the Powershell Webserver deliver encrypted traffic. For a description look here.
There is no security!!! Once started the webserver can be accessed by everyone and everyone can do on the webserver system what you can do.
There is no optimization for large file download or uploads (no chunking or similiar techniques). The transfer of large files might work, or might not.
| Back | FazBrowse Home | New Git URL |