Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-9196

powershell : Write-Error cmdlet stderr only shows as notice instead of error

    Details

    • Type: Task
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Do
    • Affects Version/s: PowerShell 2.3.0
    • Fix Version/s: None
    • Component/s: None
    • CS Priority:
      Reviewed
    • Zendesk Ticket IDs:
      35066
    • Zendesk Ticket Count:
      1

      Description

      Basic Info
      Module Version: 2.3.0
      Puppet Version: 2019.0.x
      OS Name/Version: Windows Server 2016

      Describe your issue in as much detail as possible...

      Desired Behavior:

      When using the Write-Error cmdlet, stderr output should not appear as notice in the Puppet run and report, but instead as error.

      C:\Users\Administrator\Desktop>puppet agent -t
      Notice: Compiled catalog for gpf8tqi52wxosi2.delivery.puppetlabs.net in environment production in 0.25 seconds
      Notice: /Stage[main]/Main/Exec[write-host]/returns:
      Notice: /Stage[main]/Main/Exec[write-host]/returns: $foo = "bar"
      Notice: /Stage[main]/Main/Exec[write-host]/returns: $foo = "bar"
      Notice: /Stage[main]/Main/Exec[write-host]/returns: write-error "Error running script"
      Error: /Stage[main]/Main/Exec[write-host]/returns: exit 1 : Error running script
      Notice: /Stage[main]/Main/Exec[write-host]/returns: + CategoryInfo : NotSpecified: ( [Write-Error], WriteErrorException
      Notice: /Stage[main]/Main/Exec[write-host]/returns: + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
      Notice: /Stage[main]/Main/Exec[write-host]/returns:
      Error: '
      $foo = "bar"
      $foo = "bar"
      write-error "Error running script"
      exit 1' returned 1 instead of one of [0]
      Error: /Stage[main]/Main/Exec[write-host]/returns: change from 'notrun' to ['0'] failed: '
      $foo = "bar"
      $foo = "bar"
      write-error "Error running script"
      exit 1' returned 1 instead of one of [0]
      Notice: Applied catalog in 1.92 seconds

      C:\Users\Administrator\Desktop>

      Actual Behavior:

      Running the following code it produces a notice output for Write-Error .

       

      exec { 'write-host':
      command => '
      $foo = "bar"
      $foo = "bar"
      write-error "Error running script"
      exit 1',
      provider => powershell,
      logoutput => on_failure
       }
      

       

      C:\Users\Administrator\Desktop>puppet agent -t
      Info: Using configured environment 'production'
      Info: Retrieving pluginfacts
      Info: Retrieving plugin
      Info: Retrieving locales
      Info: Loading facts
      Info: Caching catalog for mkkewkmd4er8gi0.delivery.puppetlabs.net
      Info: Applying configuration version 'pe-201902-master-production-cf52578195f'
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns:
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns: $foo = "bar"
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns: $foo = "bar"
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns:
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns: write-error "Error running script"
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns: exit 1 : Error running script
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns: + CategoryInfo : NotSpecified: ( [Write-Error], WriteErrorException
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns: + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
      Notice: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns:
      Error: '
      $foo = "bar"
      $foo = "bar"

      write-error "Error running script"
      exit 1' returned 1 instead of one of [0]
      Error: /Stage[main]/Main/Node[mkkewkmd4er8gi0.delivery.puppetlabs.net]/Exec[write-host]/returns: change from 'notrun' to ['0'] failed: '
      $foo = "bar"
      $foo = "bar"

      write-error "Error running script"
      exit 1' returned 1 instead of one of [0]
      Notice: Applied catalog in 1.97 seconds

      C:\Users\Administrator\Desktop>

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michael.lombardi Michael Lombardi
                Reporter:
                kyle.hansel Kyle Hansel
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support