René's URL Explorer Experiment


Title: Redirection vs. -*Variable common parameters, and the limited usefulness of the data that is captured · Issue #10236 · PowerShell/PowerShell · GitHub

Open Graph Title: Redirection vs. -*Variable common parameters, and the limited usefulness of the data that is captured · Issue #10236 · PowerShell/PowerShell

X Title: Redirection vs. -*Variable common parameters, and the limited usefulness of the data that is captured · Issue #10236 · PowerShell/PowerShell

Description: I'm working on #6702 right now, normalizing the stream-related common parameters so that you can capture a stream in a variable or provide an ActionPreference for any stream, when I came across what appears to be a design bug. It's easie...

Open Graph Description: I'm working on #6702 right now, normalizing the stream-related common parameters so that you can capture a stream in a variable or provide an ActionPreference for any stream, when I came across wha...

X Description: I'm working on #6702 right now, normalizing the stream-related common parameters so that you can capture a stream in a variable or provide an ActionPreference for any stream, when I came across...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10236

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Redirection vs. -*Variable common parameters, and the limited usefulness of the data that is captured","articleBody":"I'm working on #6702 right now, normalizing the stream-related common parameters so that you can capture a stream in a variable or provide an `ActionPreference` for any stream, when I came across what appears to be a design bug.\r\n\r\nIt's easier to understand when looking at an example, so run this script first to get started:\r\n\r\n```powershell\r\n# Capture a warning using redirection\r\n$o1 = Write-Warning 'Message' 3\u003e\u00261\r\n\r\n# Capture a warning using -WarningVariable\r\n$o2 = $null\r\nWrite-Warning 'Message' -WarningVariable o2\r\n\r\n# Capture a warning using a -WarningVariable while silencing output via -WarningAction\r\n$o3 = $null\r\nWrite-Warning 'Message' -WarningVariable o3 -WarningAction Ignore\r\n\r\n# Capture a warning using a -WarningVariable while silencing output via redirection\r\n$o4 = $null\r\nWrite-Warning 'Message' -WarningVariable o4 *\u003e$null\r\n\r\n# Look at the default output, and notice the rendering differences\r\n$o1,$o2,$o3,$o4\r\n\r\n# Look at the list output, and notice how the rendering differences persist\r\n$o1,$o2,$o3,$o4 | Format-List * -Force\r\n\r\n# Look at the string output, and notice that you can't tell at all that the messages\r\n# came from warnings\r\n$o1,$o2,$o3,$o4 | Out-String\r\n```\r\n\r\nWhile each of these commands are designed to capture warning records, there are several problems that this output illustrates, as follows:\r\n\r\n1. All `WarningRecord` instances captured while redirection is used are decorated with additional information that is not captured when redirection is not used.\r\n1. `WarningRecord` instances are indistinguishable from other output when converted to string, such as when the results of a command are captured and written to a log file.\r\n1. PowerShell hosts not only apply specific colors to records from various streams, they also render additional text before the object data, even when that object data is displayed in its non-default format such as a list or a table.\r\n\r\nThe exact same behavior holds true for verbose and debug message streams, as can be seen through the PR that I am working on.\r\n\r\nThe first issue is not a huge issue, but it would probably be better if records captured via `-*Variable` common parameters were also properly decorated for proper output in a console.\r\n\r\nThe second and third issue are the more serious problem, because they limit the usefulness of capturing various types of stream data. Scripters who run a command and want to capture and review results from a log will find that much easier if output from different streams is properly identified in a black and white format with a prefix. This isn't just nice to have information: it's critical for scanning and searching purposes.\r\n\r\nDigging into the technical details, part of the problems stem from these methods in the default host implementation:\r\n\r\n```none\r\n   TypeName: System.Management.Automation.Internal.Host.InternalHostUserInterface\r\nName             MemberType Definition\r\n----             ---------- ----------\r\nWrite            Method     void Write(string value), void Write(System.ConsoleColor foregroundColor, System.ConsoleColor backgroundColor, string value)\r\nWriteDebugLine   Method     void WriteDebugLine(string message)\r\nWriteErrorLine   Method     void WriteErrorLine(string value)\r\nWriteInformation Method     void WriteInformation(System.Management.Automation.InformationRecord record)\r\nWriteLine        Method     void WriteLine(), void WriteLine(string value), void WriteLine(System.ConsoleColor foregroundColor, System.ConsoleColor backgroundColor, string value)\r\nWriteProgress    Method     void WriteProgress(long sourceId, System.Management.Automation.ProgressRecord record)\r\nWriteVerboseLine Method     void WriteVerboseLine(string message)\r\nWriteWarningLine Method     void WriteWarningLine(string message)\r\n````\r\n\r\nNotice how progress and information streams have methods that accept actual records, but error, warning, verbose and debug streams only have methods that accept strings. Also note that some of these methods decorate output with stream-identifying text (`WriteDebugLine`, `WriteVerboseLine`, `WriteWarningLine`), while others do not (`WriteInformation`, `WriteErrorLine`).\r\n\r\nWhat I think should happen to address this issue and provide a much better foundation for script logging going forward:\r\n\r\n1. New methods should be added to an abstract `PSHostUserInterface2` class that is derived from `PSHostUserInterface` to avoid breaking changes. There should be one `Write*Line` method and one `Write*` method for each stream.\r\n1. Once the abstract methods are added, internal classes that derive from `PSHostUserInterface` should derive from the new `PSHostUserInterface2` class and implement the new methods. Other hosts can catch up when they're ready to do so.\r\n1. The F\u0026O layer should decorate the default output of Warning, Verbose, Debug, and Information records with an all caps prefix so that they can be properly identified and searched for when all you have is text data to work with (e.g. log files).\r\n1. Any internal classes that output stream data to the host should apply a prefix in the `Write*Line` methods, but not apply in the `Write*` methods (for those we rely on the default output from the F\u0026O layer for those records). That allows for prefixing in text written directly to the host while leveraging prefixing that is inherent in the default format applied to stream record instances.\r\n\r\nThoughts/comments are welcome and appreciated.\r\n\r\n# Environment data\r\n\r\n```none\r\nName                           Value\r\n----                           -----\r\nPSVersion                      6.2.1\r\nPSEdition                      Core\r\nGitCommitId                    6.2.1\r\nOS                             Microsoft Windows 10.0.17763\r\nPlatform                       Win32NT\r\nPSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion      2.3\r\nSerializationVersion           1.1.0.1\r\nWSManStackVersion              3.0\r\n```\r\n","author":{"url":"https://github.com/KirkMunro","@type":"Person","name":"KirkMunro"},"datePublished":"2019-07-27T00:25:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/10236/PowerShell/issues/10236"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:68e075fd-68d5-7c16-4865-ec0caa24a841
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDB98:3F527:91128:EFC23:6A59F047
html-safe-nonced160824eb64cc4ab5876f481cf28aba9db71e37918833b058d91631f5e79b1dd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjk4OjNGNTI3OjkxMTI4OkVGQzIzOjZBNTlGMDQ3IiwidmlzaXRvcl9pZCI6IjYzNTc0ODIxMjYwMDM3OTM5OTEiLCJyZWdpb25fZWRnZSI6Indlc3R1czIiLCJyZWdpb25fcmVuZGVyIjoid2VzdHVzMiJ9
visitor-hmac69dc19627f77e82ede8dc3e540db4374684240c9d51f111ca148dfeab38dfc78
hovercard-subject-tagissue:473577430
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/10236/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a83d575f952154d094f8f09c1b4efce684dc2699d2cec4145a6f3f5da95780eb/PowerShell/PowerShell/issues/10236
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a83d575f952154d094f8f09c1b4efce684dc2699d2cec4145a6f3f5da95780eb/PowerShell/PowerShell/issues/10236
og:image:altI'm working on #6702 right now, normalizing the stream-related common parameters so that you can capture a stream in a variable or provide an ActionPreference for any stream, when I came across wha...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKirkMunro
hostnamegithub.com
expected-hostnamegithub.com
Noneba3976babb66479b1c943a8edc0777d96157da48fadc0161f9ddb219deee8353
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release24801cf86623a319252348d1fd69122ad974b842
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/10236#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F10236
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F10236
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/10236
Reloadhttps://github.com/PowerShell/PowerShell/issues/10236
Reloadhttps://github.com/PowerShell/PowerShell/issues/10236
Please reload this pagehttps://github.com/PowerShell/PowerShell/issues/10236
PowerShell https://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Notifications https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Fork 8.4k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Star 54.5k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Code https://github.com/PowerShell/PowerShell
Issues 1.2k https://github.com/PowerShell/PowerShell/issues
Pull requests 290 https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality 3 https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Code https://github.com/PowerShell/PowerShell
Issues https://github.com/PowerShell/PowerShell/issues
Pull requests https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Redirection vs. -*Variable common parameters, and the limited usefulness of the data that is capturedhttps://github.com/PowerShell/PowerShell/issues/10236#top
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Enginecore PowerShell engine, interpreter, and runtimehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine%22
https://github.com/KirkMunro
KirkMunrohttps://github.com/KirkMunro
on Jul 27, 2019https://github.com/PowerShell/PowerShell/issues/10236#issue-473577430
#6702https://github.com/PowerShell/PowerShell/issues/6702
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Enginecore PowerShell engine, interpreter, and runtimehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.