-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add VerboseAction, DebugAction, ProgressAction, VerboseVariable, DebugVariable, and ProgressVariable common parameters #10238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e996df8
fc21ea9
5429151
813f936
2717565
314bf05
9ee62ec
84a6eb1
9f50c65
3dfb20f
de65104
4531f36
5b101c6
a0e6e7f
d78f5bf
527e209
4440334
12b00d0
cbc54e5
716cc35
cde7ed2
20c96c0
d38e481
288e22d
497ab2b
c9fda28
4c635b7
9fda03f
82b638d
d166fb5
b04dd8a
aae169b
de32dd5
8d29bc0
a458143
18f19bf
ff1489b
c068c80
169d822
4f00c1b
c3b1932
2223f38
4ba4626
d196fe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -476,6 +476,12 @@ internal static IEnumerable<PSObject> InvokePowerShell( | |||||||
| CopyParameterFromCmdletToPowerShell(cmdlet, powerShell, "InformationAction"); | ||||||||
| CopyParameterFromCmdletToPowerShell(cmdlet, powerShell, "Verbose"); | ||||||||
| CopyParameterFromCmdletToPowerShell(cmdlet, powerShell, "Debug"); | ||||||||
| if (ExperimentalFeature.EnabledExperimentalFeatureNames.Contains("PSNewCommonParameters")) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will break if the target remote session is an older version and does not support the new common parameters. We will need to update PowerShell remote encoding to support this only for target versions that implement the new common parameters. See: PowerShell/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs Line 1103 in 0f6fe9b
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @PaulHigin, I'll look into this. I would also appreciate your thoughts on this comment from earlier, because taking that approach should allow us to deprecate
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't fully understand the comment. Can you provide an example? But it sounds like a separate issue that should be discussed apart from these changes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's really quite simple. Consider something you might do today, such as this: Import-Module Microsoft.Graph -VerboseThat gives you verbose output that is generated during module import. Once this PR is finalized/merged, you could do the same like this: Import-Module -VerboseAction ContinueBut the original syntax would work as well. Where the question comes into play is this: do we need both The latter is necessary to allow you to properly handle those streams like any other stream. The former is "necessary" for backwards compatibility and muscle memory. My point was that it is possible to support both of these with a single parameter, which would treat a switch-like invocation as if you invoked the corresponding i.e.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another data point that could influence this: using For example, this shows verbose output from Remove-Module MicrosoftTeams
# Turn off verbose messages by default
$VerbosePreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
& {
[CmdletBinding()]
param()
Write-Verbose 'Am I showing verbose output?'
Import-Module MicrosoftTeams
} -VerboseUnfortunately, so does this, which is unexpected: Remove-Module MicrosoftTeams
# Turn on verbose messages by default
$VerbosePreference = [System.Management.Automation.ActionPreference]::Continue
& {
[CmdletBinding()]
param()
Write-Verbose 'Am I showing verbose output?'
Import-Module MicrosoftTeams
} -Verbose:$falseWhy would |
||||||||
| { | ||||||||
| CopyParameterFromCmdletToPowerShell(cmdlet, powerShell, "VerboseAction"); | ||||||||
| CopyParameterFromCmdletToPowerShell(cmdlet, powerShell, "DebugAction"); | ||||||||
| CopyParameterFromCmdletToPowerShell(cmdlet, powerShell, "ProgressAction"); | ||||||||
| } | ||||||||
|
|
||||||||
| var invocationSettings = new PSInvocationSettings { Host = cmdlet.Host }; | ||||||||
|
|
||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.