Skip to content

Test-Connection -Quiet not working #10370

Closed

Description

In PowerShell v5, Test-Connection -Quiet will return True or False, in PowerShell Core 6.2.2, it still returns the entire ping result. In scripts I have that pipe the result to Out-Null, it works fine in v5, but 6.2.2 still outputs data.

image

Activity

  1. added
    Issue-Question
    on Aug 16, 2019
  2. vexx32 commented on Aug 16, 2019

    @vexx32
    Collaborator

    This is a duplicate of #6768

    I also have an in progress draft PR #10044 that will resolve this specific issue as well as add some additional improvements. I plan to finish it before PS7 release, but I have not had a lot of time to work on it recently. I'll see if I can get the kinks ironed out by this weekend, and then start getting the necessary PRs in, one at a time. 🙂

    Also, the additional output in 6.2.2 is actually not output. It's data sent to the Information stream with a PSHOST tag to force it to display (much like how Write-Host works). It will only display in the console, not actually affecting the output of your script if you capture it into variables or pipe to Out-Null.

    You can suppress the information stream data in a few ways, but you'll need to work with the redirection operator to do so. One way might be:

    $( $Result = Test-Connection 1.1.1.1 -Quiet ) 6> $null
  3. clsmith70 commented on Aug 16, 2019

    @clsmith70
    Author

    That makes sense. I only posted after testing it out when one of the functions in a custom module for work was returning the result from Test-Connection that is piped to Out-Null in the script. It does not output any results in PS v5.1, but in PS 6.2 it does. I'll rewrite one of the functions and add something similar to your example above and test it out. This should suffice until your work is complete.

    Thanks Rain Sallow (/u/ta11ow) (@vexx32)!

  4. tibmeister commented on Sep 25, 2019

    @tibmeister

    I don't know if I would close this as resolved because the root issue is still not resolved, being that -Quiet still does absolutely nothing and I don't get a $True/$False return easily. How about we fix this before closing it, or I don't know, re-introduce the original code from 2 years ago that already had this fixed without needing this stupid workaround.

  5. vexx32 commented on Sep 25, 2019

    @vexx32
    Collaborator

    You will in ps7. I have a PR that addresses this which I think is already merged, and there are further PRs in review that will further improve the output from Test-Connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionResolution-Answered

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions