Invoke-WebRequest

This topic contains 3 replies, has 3 voices, and was last updated by  Don Jones 3 years, 10 months ago.

  • Author
    Posts
  • #10541

    Michael Craig
    Participant

    Hello,

    I've been playing with Invoke-WebRequest, to write a very simple 'soak test' for some of our web services. I've noticed some very strange behavior when I'm running this, see screen shot attached.

    Any ideas why Powershell is throwing a popup notification?

    Import-Module WebAdministration
    $cred = Get-Credential
    ri output.csv -Force
    1..1000000 | %{
    	Invoke-WebRequest -Uri "https://myhost:1443/Service/rest/Get?ProductTypeFilter=abc&Key=7007009&BlobTypeFilter=Sales&MaxNumOfBlobs=10" -Credential $cred | select -ExpandProperty content | %{Write-Output "myhost:1443 `t $_"} | Out-File output.csv -Append 
    
    }
    

    Thanks,

    Mike

  • #10547

    Richard Siddaway
    Moderator

    Hi – the screen shot isn't clear – its not fully visible – but it seems to be some kind of progress bar. Can you supply a clearer screen shot?

    How much data are you expecting to be returned?
    Do you get the same issue with all calls to the service?

  • #10576

    Michael Craig
    Participant

    This only seems to occur when I'm running requests in a quick fashion. In this example it's probably doing about 7-9/second, and the popup doesn't stay long enough to get a good screen shot. The amount of data returning is very small less than 50kb..But regardless, even if the data was 1GB, there shouldn't be a popup status window should there?

    As a side note, if I run this while RDP'd into the server hosting the web service i get this second image "perf2.jpg" which I would expect ( I guess ).

    Maybe this is a Windows 7 thing?

  • #10580

    Don Jones
    Keymaster

    That "pop up" is a PowerShell progress bar, and its an inbuilt part of the Web-Request command. You can probably set $ProgressPreference='SilentlyContinue' to suppress that.

    The pop-up is rendered by the host application. So, when you're in the console host, it's a character-based pseudo-pop-up-thing. I suspect the first time you were using the ISE or some other "graphical" host, which renders the progress as an actual dialog.

You must be logged in to reply to this topic.