0

I have an installer that calls Invoke-WebRequest and then shortly after calls sudo <command>, but the line is all filled up with output from the WebRequest.

From Terminal:

pwsh

Then, from PowerShell:

Invoke-WebRequest https://google.com -OutFile /dev/null; sudo ls -al

enter image description here

How do I make sure the password prompt is visible on its own line? I prefer to not call Clear-Host, since I would like to retain output from previous commands on the screen for the user to read.

This issue is present on PowerShell for macOS and Linux, but not for Windows, since Windows' own PowerShell tends to show the progress indicator at the top of the window.

tresf
  • 7,103
  • 6
  • 40
  • 101
  • 1
    What about outputting a couple blank lines (e.g `Write-Host "`n"`) after the `Invoke-WebRequest` command? – Daniel Jan 19 '23 at 07:00
  • Did you try? When I did earlier, the terminal was still plagued by the case of the lingering download indicator. – tresf Jan 19 '23 at 07:34
  • The return is being truncated because you are using -Outfile /dev/Null. To solve issue you would need to filter the Outfile and remove everything except the return. – jdweng Jan 19 '23 at 08:05
  • @jdweng I do not understand your statement. `Invoke-WebRequest` has support for `-OutFile` and that's what I'm using. `/dev/null` is an example only. The issue is reproducible with a real outfile as well. – tresf Jan 19 '23 at 19:01
  • Not sure. The password would normally would send the return back to the terminal. I suspect the -Outfile somehow is suppressing the return. It is worth a try and see what happens. – jdweng Jan 19 '23 at 19:45
  • What is worth a try? Please be specific as possible. – tresf Jan 19 '23 at 20:02

1 Answers1

1

A viable workaround is to suppress the indicator completely, which has other major advantages...

$ProgressPreference = 'SilentlyContinue' # <---- ADD THIS LINE
Invoke-WebRequest https://google.com -OutFile /dev/null; sudo ls -al
tresf
  • 7,103
  • 6
  • 40
  • 101