Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do a fire and forget web request using PowerShell

Tags:

powershell

For a webrequest in PowerShell I use

Invoke-WebRequest -Uri 'https://www.it-takes-long.de' -UseBasicParsing

Is there a way to do a webrequest in a fire and forget way?

I call the url to warm up a web from my build server and I would rather continue to the next step and not wait for the web to start up.

like image 549
Mathias F Avatar asked Mar 03 '17 12:03

Mathias F


People also ask

What is Iwr in PowerShell?

The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of links, images, and other significant HTML elements. This cmdlet was introduced in PowerShell 3.0.

How do I call a PowerShell script from REST API?

To call a REST API from the Windows PowerShell, you should use the Invoke-RestMethod cmdlet. A call to an API is simply a request through HTTP or HTTPS. So, you will need a URL to which the API will be sent. You can find detailed information about the URL to call to get data from API documentation.

What is Uri in invoke-WebRequest?

Invoke-WebRequest sends a request to the URI (Uniform Resource Identifier) which is also called Endpoint and retrieves the data from the Web Page. It directly works with the URL or with the REST API because some websites allow modifying the content using only APIs.


1 Answers

Just put the invoke into a job using the Start-Job cmdlet:

Start-Job -ScriptBlock {Invoke-WebRequest -Uri 'https://www.it-takes-long.de' -UseBasicParsing}
like image 129
Martin Brandl Avatar answered Oct 15 '22 05:10

Martin Brandl