What are some free and portable web server options that can run from PowerShell?

0
10
Asked By DataWhiz42 On

I'm looking for a way to push about 2GB of data to multiple Windows 10 workstations and need a simple web server to host that data. This server needs to run silently using PowerShell because there's a specific application that requires it to serve the files (the app runs with the command `app.exe -url http://localhost/data`). Unfortunately, I can't make the app reference the local path directly (like `C:data`), so a web server is necessary.

I want to transfer the files and then run the web server automatically once everything is copied to `C:data`, followed by starting the app and using the hosted data. I've found some options, but they're either not free or they require a GUI, which I want to avoid. Any recommendations that are trustworthy?

4 Answers

Answered By QuickServerFinder On

I used a lightweight web server called HFS (HTTP File Server). It’s command line only, and does the job quickly. Check it out [here](https://rejetto.com/hfs/).

Answered By IISGenius On

You can actually run IIS on Windows 10 using PowerShell. Here’s a quick script you can use:

```powershell
Enable-WindowsOptionalFeature -online -featurename IIS-WebServerRole,IIS-WebServer,IIS-StaticContent,IIS-ManagementConsole -All -NoRestart
Import-Module WebAdministration
New-Website -Name "data" -PhysicalPath c:data -Port 8080 -Force
Start-Website -Name "data"
```
This sets up a lightweight server that only runs locally if you want. Just remember that you can disable it later too if needed!

CautiousAdmin -

Remember to make sure only localhost can access it for security.

ServerGuru101 -

IIS is a solid choice because it receives regular updates from Windows.

Answered By ScriptSlinger On

You might also want to consider using .NET's built-in server in PowerShell. Here’s a small script you can run:

```powershell
$httpListener = New-Object System.Net.HttpListener
$httpListener.Prefixes.Add("http://localhost:8080/")
$httpListener.Start()

try {
while ($true) {
$context = $httpListener.GetContext()
$response = $context.Response
$responseString = "File served!"
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
$response.ContentLength64 = $buffer.Length
$response.OutputStream.Write($buffer, 0, $buffer.Length)
$response.Close()
}
}
finally {
if ($httpListener.IsListening) {
$httpListener.Stop()
}
}
```
This runs a basic server that listens for requests.

CuriousTechie22 -

Does this require admin rights to set up?

PowerShellMaster30 -

It usually won't need admin rights if you're listening on localhost only.

Answered By PythonNinja89 On

If you need a quick solution, using Python is easy! You can set up a simple HTTP server with just the command `python3 -m http.server`. It's great for serving files without any graphical interface. Just make sure Python is installed on your workstations.

HelpfulTom -

This is definitely the simplest solution I've seen!

CuriousUser14 -

Thanks for the tip! I'll give it a try.

Related Questions

Keep Your Screen Awake Tool

Favicon Generator

JWT Token Decoder and Viewer

Ethernet Signal Loss Calculator

Remove Duplicate Items From List

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.