Skip to content

Fixing issue #20851 #13

Fixing issue #20851

Fixing issue #20851 #13

Triggered via dynamic June 24, 2025 16:58
Status Success
Total duration 16m 23s
Artifacts 1

copilot

on: dynamic
Fit to window
Zoom out
Zoom in

Annotations

6 warnings
copilot
a) Default: Shows = true & Expected = true\n##[warning]b) SilentlyContinue: Shows = true & Expected = false\n##[warning]c) Ignore: Shows = true & Expected = false\n##[warning]d) 3> redirect $null: Shows = true & Expected = false\n##[warning]e) 3> redirect file: Shows = true & Expected = false\n\n\nFinishing: Test PS\n```\n\n### Full task logs with system.debug enabled\n\n_No response_\n\n### Repro steps\n\n```yml\ntrigger:\n- none\n\npool:\n vmImage: windows-latest\n\nsteps:\n\n- task: PowerShell@2\n displayName: Test PS\n inputs:\n targetType: 'inline'\n showWarnings: true\n script: | \n # Should print and does\n Write-Warning \"a) Default: Shows = true & Expected = true\" \n\n # Should NOT print but does\n Write-Warning \"b) SilentlyContinue: Shows = true & Expected = false\" -WarningAction SilentlyContinue\n\n # Should NOT print but does\n Write-Warning \"c) Ignore: Shows = true & Expected = false\" -WarningAction Ignore\n\n # Should NOT print but does\n Write-Warning \"d) 3> redirect `$null: Shows = true & Expected = false\" 3> $null\n\n # Should NOT print but does\n Write-Warning \"e) 3> redirect file: Shows = true & Expected = false\" 3> out.txt\n```\n## Comments on the Issue (you are @copilot in this section)\n\n<comments>\n<comment_new>\n<comment_id>2809122566</comment_id>\n<author>@rishabhmalikMS</author>\n**Why This Happens**\n1.\tWrite-Warning Behavior:\n o\tThe -WarningAction parameter is command-specific and determines how the warning is handled at the time it is generated (e.g., displayed, suppressed).\n o\tHowever, this parameter is not stored in the WarningRecord object that represents the warning.\n2.\tWarningRecord Object:\n o\tWhen a warning is generated, it is represented as a System.Management.Automation.WarningRecord object.\n o\tThis object contains properties like:\n •\tMessage: The warning message.\n •\tInvocationInfo: Information about the command that generated the warning which does not have warningAction related details.\n o\tMissing Information: The WarningRecord does not include any details about the -WarningAction parameter or how the warning was handled.\n3.\tObservable Collection:\n o\tWhen warnings are captured using -WarningVariable and stored in an observable collection, only the WarningRecord objects are stored.\n o\tSince the WarningRecord does not include -WarningAction, it is impossible to determine the action that was passed to Write-Warning.\n \n**Implications**\n•\tYou cannot directly determine the -WarningAction value that was passed to Write-Warning by inspecting the WarningRecord object.\n•\tThis limitation makes it not feasible to display warning in conditional manner\n\n\n</comment_new>\n\n</comments>\n\n","owner":"microsoft","repo":"azure-pipelines-tasks","numSnippets":10}
copilot
e) 3> redirect file: Shows = true & Expected = false
copilot
d) 3> redirect $null: Shows = true & Expected = false
copilot
c) Ignore: Shows = true & Expected = false
copilot
b) SilentlyContinue: Shows = true & Expected = false
copilot
a) Default: Shows = true & Expected = true

Artifacts

Produced during runtime
Name Size Digest
results Expired
45.2 KB
sha256:87f6e768bcd7bd803bb4da718556376a8f7ad998ecd32e3911221c092adf5bc8