Skip to content

PSAvoidUsingWriteHost: Multiple files use Write-Host instead of Write-Output/Verbose #5

@eigenverft

Description

@eigenverft

Issue

Multiple PowerShell files use Write-Host which is discouraged in PowerShell best practices. Write-Host has several limitations:

  • Might not work in all hosts
  • Does not work when there is no host
  • Prior to PowerShell 5.0, cannot be suppressed, captured, or redirected

Affected Files

Eigenverft.Manifested.Agent.InvokeCodexTask.ps1

  • Line 612: Write-Host $text

Eigenverft.Manifested.Agent.InvokeGeminiTask.ps1

  • Line 546: Write-Host ([string]$record.Line)
  • Line 624: Write-Host ([string]$line)
  • Line 636: Write-Host ($rawStructuredOutput.TrimEnd("r", "n"))
  • Line 660: Write-Host ([string]$line)

Eigenverft.Manifested.Agent.InvokeQwenTask.ps1

  • Line 500: Write-Host ([string]$record.Line)
  • Line 582: Write-Host ([string]$line)

Recommended Fix

Replace Write-Host with appropriate alternatives:

  • Write-Output - for general output
  • Write-Verbose - for verbose/diagnostic output
  • Write-Information - for informational messages that should be suppressible

Example

# Before
Write-Host ([string]$record.Line)

# After
Write-Output ([string]$record.Line)
# or
Write-Verbose ([string]$record.Line)

PSScriptAnalyzer Rule

PSAvoidUsingWriteHost

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions