GithubHelp home page GithubHelp logo

Comments (3)

r15ch13 avatar r15ch13 commented on July 29, 2024

It seems that $host.UI.RawUI.ForegroundColor returns null with this setup.

Install/install.ps1

Lines 72 to 89 in 656e17b

function Write-InstallInfo {
param(
[Parameter(Mandatory = $True, Position = 0)]
[String] $String,
[Parameter(Mandatory = $False, Position = 1)]
[System.ConsoleColor] $ForegroundColor = $host.UI.RawUI.ForegroundColor
)
$backup = $host.UI.RawUI.ForegroundColor
if ($ForegroundColor -ne $host.UI.RawUI.ForegroundColor) {
$host.UI.RawUI.ForegroundColor = $ForegroundColor
}
Write-Output "$String"
$host.UI.RawUI.ForegroundColor = $backup
}

Could you try this modified Write-InstallInfo function?

function Write-InstallInfo {
    param(
        [Parameter(Mandatory = $True, Position = 0)]
        [String] $String,
        [Parameter(Mandatory = $False, Position = 1)]
        [System.ConsoleColor] $ForegroundColor = 'Gray'
    )

    $backup = $host.UI.RawUI.ForegroundColor
    if ($null -eq $backup) {
        $backup = 'Gray'
    }
    if ($null -eq $ForegroundColor) {
        $ForegroundColor = 'Gray'
    }

    if ($ForegroundColor -ne $host.UI.RawUI.ForegroundColor) {
        $host.UI.RawUI.ForegroundColor = $ForegroundColor
    }

    Write-Output "$String"

    $host.UI.RawUI.ForegroundColor = $backup
}

from install.

jaw avatar jaw commented on July 29, 2024

Here is the result:

    {
      "category_info": {
        "activity": "Write-InstallInfo",
        "category": "NotSpecified",
        "category_id": 0,
        "reason": "SetValueInvocationException",
        "target_name": "",
        "target_type": ""
      },
      "error_details": null,
      "exception": {
        "help_link": null,
        "hresult": -2146233087,
        "inner_exception": {
          "help_link": null,
          "hresult": -2146233087,
          "inner_exception": null,
          "message": "A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows.",
          "source": "System.Management.Automation",
          "type": "System.Management.Automation.Host.HostException"
        },
        "message": "Exception setting \"ForegroundColor\": \"A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows.\"",
        "source": "System.Management.Automation",
        "type": "System.Management.Automation.SetValueInvocationException"
      },
      "fully_qualified_error_id": "ExceptionWhenSetting,Write-InstallInfo",
      "output": "Write-InstallInfo : Exception setting \"ForegroundColor\": \"A command that prompts the user failed because the host \r\nprogram or the command type does not support user interaction. Try a host program that supports user interaction, such \r\nas the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that \r\ndo not support user interaction, such as Windows PowerShell workflows.\"\r\nAt C:\\downloads\\scoop\\scoop_install.ps1:561 char:5\r\n+     Write-InstallInfo \"Initializing...\"\r\n+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : NotSpecified: (:) [Write-InstallInfo], SetValueInvocationException\r\n    + FullyQualifiedErrorId : ExceptionWhenSetting,Write-InstallInfo\r\n \r\n",
      "pipeline_iteration_info": [
        0,
        1
      ],
      "script_stack_trace": "at Write-InstallInfo, C:\\downloads\\scoop\\scoop_install.ps1: line 89\r\nat Install-Scoop, C:\\downloads\\scoop\\scoop_install.ps1: line 561\r\nat <ScriptBlock>, C:\\downloads\\scoop\\scoop_install.ps1: line 700\r\nat <ScriptBlock>, <No file>: line 2",
      "target_object": null
    }

from install.

xPancakery avatar xPancakery commented on July 29, 2024

I am also getting this error, to validate the other users bug report.

from install.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.