Skip to content

[BUG]: Powershell@2 Impossible to ignore specific warning output #20851

Open
@arc-hbas

Description

New issue checklist

Task name

Powershell

Task version

2

Issue Description

When using the PowerShell@2 task and enabling showWarnings, it becomes impossible to specifically ignore a single warning, even if WarningAction is set to Ignore or SilentlyContinue. Other "hacks", such as using redirect operator 3> to redirect warning output stream to file or $null, have not been successful to workaround this issue. This potentially causes massive log clutter when you still want to surface warning output to the pipeline summary view, but would like to disregard some of the non-important ones.

Running below example YAML pipeline, all of the warnings are still surfaced:

Image

Image

I thought surely the 3> redirect would work, but alas it doesn't. Thus far I have been unable to find any sort of workaround. Warnings are helpful, but only when they're relevant. Sometimes we call system level or pre-built cmdlets and cannot expect them to only print out relevant warnings (from our perspective at least).

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows

Relevant log output

...
WARNING: a) Default: Shows = true & Expected = true
##[warning]a) Default: Shows = true & Expected = true
##[warning]b) SilentlyContinue: Shows = true & Expected = false
##[warning]c) Ignore: Shows = true & Expected = false
##[warning]d) 3> redirect $null: Shows = true & Expected = false
##[warning]e) 3> redirect file: Shows = true & Expected = false


Finishing: Test PS

Full task logs with system.debug enabled

No response

Repro steps

trigger:
- none

pool:
  vmImage: windows-latest

steps:

- task: PowerShell@2
  displayName: Test PS
  inputs:
    targetType: 'inline'
    showWarnings: true
    script: |      
      # Should print and does
      Write-Warning "a) Default: Shows = true & Expected = true" 

      # Should NOT print but does
      Write-Warning "b) SilentlyContinue: Shows = true & Expected = false" -WarningAction SilentlyContinue

      # Should NOT print but does
      Write-Warning "c) Ignore: Shows = true & Expected = false" -WarningAction Ignore

      # Should NOT print but does
      Write-Warning "d) 3> redirect `$null: Shows = true & Expected = false" 3> $null

      # Should NOT print but does
      Write-Warning "e) 3> redirect file: Shows = true & Expected = false" 3> out.txt

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions