The Invoke-HttpServer function starts an HTTP server that listens for incoming requests on a specified IP and port. It processes requests in a separate runspace and provides request details in the console. The answer served to the client can be customized. The server can be configured for different IP addresses, ports, and timeout durations. It runs in a loop until the specified timeout is reached or it is manually stopped (Ctrl+C). The server has built-in error handling to handle common issues like conflicting ports and access permissions.
This will start an HTTP server on all interfaces and port 8080. The server will run for 120 seconds before shutting down automatically. Note: To expose the server in the local network, the command has to be executed as admin.