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
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/).
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!
IIS is a solid choice because it receives regular updates from Windows.
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.
Does this require admin rights to set up?
It usually won't need admin rights if you're listening on localhost only.
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.
This is definitely the simplest solution I've seen!
Thanks for the tip! I'll give it a try.

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