Repository navigation
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues
Description
Steps to reproduce
> $TestConnection = Test-Connection 8.8.8.8 -Count 3 Expected behavior
> $TestConnection = Test-Connection 8.8.8.8 -Count 3
> $TestConnection
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
MacBook-Pro... 8.8.8.8 8.8.8.8 32 29
MacBook-Pro... 8.8.8.8 8.8.8.8 32 29
MacBook-Pro... 8.8.8.8 8.8.8.8 32 29
MacBook-Pro... 8.8.8.8 8.8.8.8 32 29
MacBook-Pro... 8.8.8.8 8.8.8.8 32 28
MacBook-Pro... 8.8.8.8 8.8.8.8 32 29
MacBook-Pro... 8.8.8.8 8.8.8.8 32 29
MacBook-Pro... 8.8.8.8 8.8.8.8 32 29
MacBook-Pro... 8.8.8.8 8.8.8.8 32 30
MacBook-Pro... 8.8.8.8 8.8.8.8 32 28
Actual behavior
> $TestConnection = Test-Connection 8.8.8.8 -Count 3
Pinging 8.8.8.8 [8.8.8.8] with 32 bytes of data:
Reply from 8.8.8.8: bytes=0 time=31ms TTL=
Reply from 8.8.8.8: bytes=0 time=31ms TTL=
Reply from 8.8.8.8: bytes=0 time=31ms TTL=
Ping complete.
> $TestConnection
Source Destination Replies ------ ----------- -------
MacBook-Pro.localdomain 8.8.8.8 {System.Net.NetworkInformation.PingReply, System.Net.NetworkInformation.PingReply...
Environment data
> $PSVersionTable
Name Value ---- -----
PSVersion 6.1.0-rc.1
PSEdition Core
GitCommitId 6.1.0-rc.1
OS Darwin 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:59:21 PDT 2...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Reacted by Ralph Lewis
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues
Activity
Graham-Beer commentedon Sep 25, 2018
The issue with the output extends to -quiet switch parameter as well. As well of just returning true/false, also have a visable ping reponse.
RichardSiddaway commentedon Oct 18, 2018
This is still an issue in v6.2 preview that has just been made available. is it likely to be resolved? The current output while the pings are happening is just acceptable in an interactive session but is unnecessary when running a script.
Why do we need the write-progress bar for a ping? That's just totally unnecessary when the same data is echoed in the text output.
The final output needs the replies unwrapping, Delivering a collection of .NET objects under the Replies heading doesn't make sense.
The current implementation looks like a work in progress that was abandoned.
vexx32 commentedon Oct 20, 2018
I'll take a look. It's probably relatively simple. 😄
SteveL-MSFT commentedon Oct 20, 2018
Windows PowerShell used the WMI Win32_PingStatus class and each object in the output is an instance of Win32_PingStatus. Since WMI and that class is Windows specific,
Test-Connectionneeded to be rewritten for ICMP pings to work cross platform. It was reimplemented using the NetInformation.Ping class. The output you see at the console which resembles thepingcommand output is synthetic and is written to the Information channel. If you don't want to see it, you can do:The new summary object that is returned is arguably more useful than the Win32_PingStatus instances that you would need to evaluate to determine if it was overall successful or not.
vexx32 commentedon Oct 20, 2018
Yeah, sure you can
-InformationAction Ignore, but why is that necessary to avoid polluting host output? Why does it utilise a method that is otherwise restricted toWrite-Hostto output data that isn't wanted, especially with the-Quietflag applied?It's a very un-PowerShell mode of operation, from what I can see. 😕
SteveL-MSFT commentedon Oct 20, 2018
#5328 ported
Test-Connectionto using .NET APIs. There was an ask within the PR for feedback on the output, but it didn't get much attention back then. I'm open to any proposals on how we can improve the experience. cc Ilya (@iSazonov)vexx32 commentedon Oct 20, 2018
My thoughts, after playing around with the code:
WriteProgress. Currently it displays only the exact same data as is being shown in the host output. There is no reason for its inclusion here. If, for example, it was hidden behind an optional switch, or configured to display actual progress (i.e., number of pings attempted thus far out of total count being attempted) then perhaps it could be useful.-TraceRoute. It makes sense there, but given the object-oriented nature of PowerShell, there being host output by default as well as an object in the output stream is very weird and counter to the behaviour of basically every other cmdlet in existence.-TraceRoutecode paths so that it doesn't display by default.I mean, look at it:
Very not-useful. All you get is source and destination, which you probably already know, since you executed the command in the first place, and a bunch of meaningless type names.
I would suggest in terms of the default formatting, it ought to ditch the third column entirely (keep it structured that way internally for querying purposes), and add some new ones (both to formatting display and the actual objects):
Status: Success)So, the "summary object" ought to actually be a useful summary, with the individual
.Repliesstill present but hidden in the default formatting, while remaining readily available for the user to work with, should they need to.Sample display of the above suggestion of default display:
Much more useful to work with, no? For reference, this is the wrangling needed to get useful display out of this command:
It's a bit much, don'tcha think? 😄
Sidenote:
-TraceRoutealso produces differently-structured objects, and I think should have a different approach to the summary object. It probably ought to output a series of summary objects similar to the aforementioned ones, one for each host it tries to reach in the trace.insert hacker montage for the kids
So I managed to accomplish most of this (removing write-progress, updating the standard summary object, hiding majority of host display) pretty easily and if you guys want this to change I can happily submit a PR for this.
There may be more elegant solutions available to those of you more familiar with the code, however. (Also, I need to look into how the heck output formatting is defined now...)
RichardSiddaway commentedon Oct 20, 2018
Using Windows PowerShell v5.1 (and earlier) I get
One result displayed per ping
On PowerShell v6.2 preview 1 and v6.1 I get
Plus the Write-Progress bar is visible. I agree with Rain Sallow (/u/ta11ow) (@vexx32) that the progress shouldn't be displayed at all. If it must be used make it an option not the default.
With regard to the text
Pinging 127.0.0.1 [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time=0ms TTL=128
etc
that is displayed again make optional - possibly through the -Verbose parameter. if I'm using Test-Connection is code I don't want this extra output.
Finally with respect to the final output - it should be a single object per ping attempt that contains
This makes the v6 output and usage closer to the v5.1 which will avoid a lot of user confusion and make cross platform scripting easier if there's as consistent an experience as possible.
iSazonov commentedon Oct 20, 2018
The current implementation is experimental port to get feedback.
There is two scenario - interactive and script - and both clash. In interactive one we want verbose console output and in script one we don't want console output.
Also we could not want progress bar for ping but want for traceroute - we need feedback for all options.
There is plans to enhance the cmdlet (pathping, detect dumb routes...).
There is bugs in CoreFX. We have a tracking issue. Without fixing it we can not get well working Test-Connection.
Also... Rain Sallow (/u/ta11ow) (@vexx32) The cmdlet is sometimes tricky. It does reverse lookups to show real information not user input.
iSazonov commentedon Oct 20, 2018
It is absolutely impossible as Steve Lee (@SteveL-MSFT) said.
vexx32 commentedon Oct 20, 2018
There could definitely be a need for the default display in an interactive scenario. But in none of the scenarios is the
WriteProgress()useful. It gives identical information to what is being passed to host. If it is kept, it should be utilised properly as suggest; otherwise, it can be removed as it really adds nothing. Additionally,-Quietshould absolutely suppress all display. That is the dictionary definition of "Quiet".I disagree. There may be bugs, but we should make a best effort to give useful information to the user, not sit and wait while the bugs don't get fixed for months or years. The implementation can be updated when the bugs are fixed, but in the meantime it should at least be meaningfully usable in both an interactive and programmatic way.
Sidenote: Do you have a link to this issue?
I noticed. This can simply be added to the available information in the internal PingReply objects.
After some tweaking, this is the output:
This took maybe a half hour, and is using the exact same information that the cmdlet already pulls from. If we add a default format for this object, the
ftcall is unnecessary, and it fits in perfectly well with the PS Core ecosystem.Given that it is this easy to pull the information you would normally get into a PowerShell standard format, I see no actual need for the current status display utilising the host output. User gets the same display in a PS Core-standard format if needed, and if they want to use it programmatically it is automatically hidden instead of being a frustrating experience to suppress. As RichardSiddaway mentions, this kind of information is typically reserved for the
Verbosestream and should follow that pattern here, in my opinion.Frankly, the fact that use of the
"PSHOST"tag inWriteInformation()mandates the use of theIgnorestate and does not respectSilentlyContinueon-InformationActionis itself obtuse and counter to other stream behaviours, but that's another issue.I would love to see the cmdlet further expanded, but I think the immediate focus should be on making it somewhat comparable to the expected output from PS 5.1. It need not be identical, the objects need not be the same, but it should be relatively comparable.
There is no sense in building upon a foundation that is incomplete.
vexx32 commentedon Oct 20, 2018
Additionally, the objects output in the case of a
-Traceroutesuffer the same problems; information is completely buried in the reply list properties instead of being sensibly displayed. I suspect this information may also make more sense tabulated as separate object entries with the right data, again leaving the information stream/host output unnecessary and best relegated to the Verbose stream.Having a look. 😄
The Traceroute objects appear to be the bugged ones; the response statuses and roundtrip times don't get returned correctly. I'm guessing this is the CoreFX bug you mentioned Ilya (@iSazonov)?
I would agree that these should be fixed in CoreFX, but in the meantime we should code for it as though they are fixed first, with some mediation for unintelligible results for better UX -- although it will show meaningless and empty data at this point in time, it will at some point be fixed (I would hope!) and we should be ready for it, not waiting for it to happen first.
13 remaining items
vexx32 commentedon Oct 21, 2018
Right, but why not simply emulate that in the object output, just like every other cmdlet in PowerShell?
Get-ChildItememulates or approximates display of thedir/lscommand whilst actually outputting objects with the same data that is programmatically useful. Host output cannot be used in this way, cannot be piped, and is difficult to suppress (have to use-InformationAction Ignoreinstead ofSilentlyContinuelike every other stream in existence, which makes discovering the method of suppression more difficult).This is what I have attempted to do in my brief attempt (see prior comments for initial results), and I would think that users would prefer to be able to use the displayed data over providing exact output of 1990s-era DOS/linux
pingutility output.iSazonov commentedon Oct 22, 2018
Currently our formatting system doesn't support footers/summaries and titles-before-header-line. We have a tracking issue for
dir. Here is the same problem.SteveL-MSFT commentedon Oct 22, 2018
My personal opinion is that we shouldn't have progress for ping as I agree it's typically a short operation that doesn't warrant progress. The information channel should be changed to verbose for those that want it. Perhaps a new switch to emit summary or per ping objects. Default should probably be the current summary object to avoid another breaking change.
vexx32 commentedon Oct 22, 2018
There is a
-Continuesthat emits individual ping objects until you cancel, and the-MTUSizeswitch does something similar, but only a single object.If we keep the current summary object either a) the summary object's structure needs to change, and/or b) the default formatter needs to expose summary properties for the contained ping objects.
As it is, the current display of the ping summary is pretty nonexistent without the information/host display, which is probably why it was considered necessary in the first place. The immediately available properties are pretty limited without digging into the individual ping objects, as well.
SteveL-MSFT commentedon Oct 22, 2018
Rain Sallow (/u/ta11ow) (@vexx32) agree that the formatting needs to be improved. I like some of the proposals you've made in this thread. However, I'm not a heavy user of
Test-Connectionmyself so will defer to people who use it more heavily.iSazonov commentedon Nov 9, 2018
Rain Sallow (/u/ta11ow) (@vexx32) I'll look your PR although I believe we need do more design before we'll able to enhance/fix something.
vexx32 commentedon Nov 9, 2018
I agree. I figured having some ideas set down in code to look at might help us work out possible design improvements. 😄
SteveL-MSFT commentedon Nov 10, 2018
Rain Sallow (/u/ta11ow) (@vexx32) don't forget you can put it behind an Experimental Feature flag so that we can try out different options in code before deciding on a final design
vexx32 commentedon Nov 10, 2018
!! Ah, of course!
I'll see if I can set aside the time this weekend to figure out how that will work... Might be a little tricky with how I opted to make it happen, but I'm sure I can figure something out!
iSazonov commentedon Nov 10, 2018
I reviewed all feedbacks and I am strongly convinced that our train should go in a different direction.
I have a short message and a long one (Michael Klement (@mklement0) sorry you had to do it 😄 ).
In short we could, can, should and must address one main script scenario. That is a test connection. I mean a ping with
Quietparameter. This is what is most often used in scripts. I agree that we can remove all host output. I agree that we can remove a progress bar (temporarily until the progress bar subsystem improvement).That's all we can do today. Everything else "depends on" and I would postpone these exercises.
Long message.
I would have corrected this scenario (quiet ping) a long time ago, but every month we receive a new feedback (that is not directly related to this), which gives us hope that something more can be done.
Below are ideas I’m sure:
We should preserve standard dotnet types.
We have several issues that suggest that adding new properties to standard types degrades performance and creates other difficulties. (Although this opportunity remains very attractive.)
What is the right way? There are two ways to add new properties. Improve CoreFX. Improve formatting subsystem.
Cmdlets should not care about formatting output. This is an area for formatting subsystem.
Currently in interactive sessions a pipeline implicitly ends with Default-Output. This is what smart formatting should do. Perhaps the only smart thing that this cmdlet can do now is to collect objects with a delay and display a table, although this has side problems and looks as a hack.
The best idea for improving the formatting subsystem is discussed in PSCore issue.
I think it is worth to make every effort to implement it as quickly as possible. I guess we can do it step by step although Jason is not sure about it.
Progress bar subsystem must be smarter.
Currently the subsystem consumes a lot of resources, does a lot of allocations, does a lot of locks, slows down scripts and it is ill suited for multi-threading.
Today there is no exact way to do it better, but we already have useful feedbacks.
Clearly this should benefit from asynchronous.