Hello there,
This is made possible by the .NET HttpListener.
- Create and Start the HTTP Listener
$httpListener = New-Object System.Net.HttpListener
$httpListener.Prefixes.Add('http://localhost:5001/')
$httpListener.Start()
Here, I’m listening for requests aimed at http://localhost:5001/, but you could listen to any other interface or port on your machine.
Listen on all interfaces by using a +, like so: http://+:5001/
HttpListener requires that you include a trailing / in the prefix.
In a separate PowerShell session:
Invoke-WebRequest 'http://localhost:5001/big-test'
You could kick off a request from anywhere though. It doesn’t have to be from PowerShell or even from your machine.
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer–