Start-TestWebServer

#powershell, #onlinehelp edit this page

Start-TestWebServer

SYNOPSIS

Webserver for load balancer testing.

SYNTAX

Start-TestWebServer.ps1 [[-Port] <Int32>] [-CreateFirewallRule]

DESCRIPTION

Start a web listener that listens on a specified port and simply answers to any request, returning JSON object containing the request. Requires administrative rights to create the listener.

EXAMPLES

————————– EXAMPLE 1 ————————–

.\Start-TestWebServer -Port 8001

Start the test WebServer on port 8001.

————————– EXAMPLE 2 ————————–

.\Start-TestWebServer -Port 80 -CreateFirewallRule
Invoke-RestMethod -Uri http://localhost | Select-Object UserAgent

Start the test WebServer on port 80 and create a Firewall Rule to allow traffic to the specified port. The Invoke-RestMethod cmdlet is used to send a request to the listener and parse the output.

PARAMETERS

-Port

Specify a TCP port number for the HTTP listener to use. Defaults to 8000.

Type: Int32
Parameter Sets: (All)
Aliases: 

Required: False
Position: 1
Default value: 8000
Accept pipeline input: False
Accept wildcard characters: False

-CreateFirewallRule

Use this switch to automatically create a Windows Firewall rule to allow incoming connections on the specified port.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: 

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

INPUTS

None.

OUTPUTS

None.

NOTES

https://ntsystems.it/PowerShell/start-testwebserver/

Download & Source for Start-TestWebServer

The is available on the PowerShell Gallery, you can install or download it using the following commands:

Install- -Name Start-TestWebServer -Scope CurrentUser
Save- -Name Start-TestWebServer -Path <Path>

And you can find the source on GitHub: tomtorggler/PowerShell