microsoft / microsoft/Analysis-Services

Write-Host ForegroundColor error on Linux: "-1 is not a valid color"

Open
#372 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
732
Forks
433
PR merge metrics
No merged PRs in 30d

Description

When running the PowerShell script on Linux using PowerShell (pwsh), the script throws the following error:

Write-Host: Cannot process the color because -1 is not a valid color. (Parameter 'value')

This happens because the script uses:

as the default value for -ForegroundColor in Write-Host.
In some Linux or non-interactive environments (for example CI/CD pipelines), System.Console::ForegroundColor returns -1, which is not a valid ConsoleColor value.

As a result, Write-Host fails when the script tries to use this value.

Can we add a condition to enforce a color in case ForegroundColor is not set.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the PowerShell script and the Write-Host parameter that defaults to [System.Console]::ForegroundColor. Reproduce the issue in Linux or a non-interactive environment, then verify that a valid fallback color is used when the value is -1 and that Write-Host completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.