Google Chrome allows you to copy an executed xhr request and replay it in PowerShell:

  • Open the developer tools (F12)

  • Open the network tab

  • Trigger the netwerk request by executing the functionality in you web application

  • Right click the request in the network tab, then “Copy” and then “Copy as PowerShell”

 

Now paste this in a PowerShell prompt and you should get the same result as in the browser.

 

If the request returns an exception (http error code), then you can use the following code to get more information on the error:

Just replace the text “<< paste request from google Chrome here >>” with the copied xhr request.

 

try {

  $webResponse = << paste request from google Chrome here >>

 

  Write-Host “Response: $($webResponse)”

}

catch {

  Write-Host “ErrorDetails: $($_.ErrorDetails)”

  Write-Host “ExceptionResponse: $($_.Exception.Response)”

<

p style=”background: #1e1e1e”>}

 

Resources:

https://4sysops.com/archives/powershell-invoke-webrequest-parse-and-scrape-a-web-page/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.