Skip to content

Instantly share code, notes, and snippets.

@viovanov
Created August 26, 2015 21:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viovanov/40205cb1658b84c3c38d to your computer and use it in GitHub Desktop.
Save viovanov/40205cb1658b84c3c38d to your computer and use it in GitHub Desktop.
one liner for a powershell server
$l = New-Object System.Net.HttpListener ; $l.Prefixes.Add("http://+:8080/"); $l.Start(); while ($l.IsListening) { $c = $l.GetContext() ; $q = $c.Request; Write-Output (date); $r = $c.Response ; $m = [System.Text.ASCIIEncoding]::ASCII.GetBytes(((gci -path env:*) | Out-String)); $r.ContentLength64 = $m.Length ; $r.OutputStream.Write($m, 0, $m.Length) ; $r.OutputStream.Dispose(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment