"A command that prompts the user failed..."

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Adam Bertram Adam Bertram 2 years, 4 months ago.

  • Author
    Posts
  • #17873
    Profile photo of Adam Bertram
    Adam Bertram
    Participant

    I'm attempting to install and configure Powershell Web Access on a Windows Server. I've gotten the feature installed and I'm now trying to setup the web access gateway using the DSC Script resource.

    This is the code I'm using. When the web application is not there, I can manually run Install-PswaWebApplication and it does not prompt. However, when I run this DSC resource, I'm getting the error below.

    Script PsaWebAccessGateway {
                SetScript = {
                    Install-PswaWebApplication
                }
                TestScript = {
                    [bool](Get-WebApplication -Name pswa | where {$_.ApplicationPool -eq 'pswa_pool'}) -eq $true
                }
                GetScript  = {
                    $result = [bool](Get-WebApplication -Name pswa | where {$_.ApplicationPool -eq 'pswa_pool'})
                    return @{HasPsaWebAccessGatewayInstalled = $result}
                }
            }
    

    This is the error I'm getting:

    PowerShell provider MSFT_ScriptResource  failed to execute Set-TargetResource functionality with error 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. 
        + CategoryInfo          : InvalidOperation: (:) [], CimException
        + FullyQualifiedErrorId : ProviderOperationExecutionFailure
        + PSComputerName        : localhost
    
  • #17882
    Profile photo of Martin Nielsen
    Martin Nielsen
    Participant

    Install-PswaWebApplication uses Write-Host to give output (bad Microsoft...). Write-Host is not supported in a workflow context. So it breaks.

    PS C:\Windows\system32> workflow moo { Install-PswaWebApplication }
    PS C:\Windows\system32> moo
    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.
        + CategoryInfo          : NotImplemented: (:) [Write-Host], HostException
        + FullyQualifiedErrorId : HostFunctionNotImplemented,Microsoft.PowerShell.Commands.WriteHostCommand ## Right there is your problem
        + PSComputerName        : [localhost]
    

    You could try hacking the Cmdlet apart and remove any Write-Host references, but that"s probably more work than fun.

  • #17904
    Profile photo of Adam Bertram
    Adam Bertram
    Participant

    Thanks! I'm new to DSC and didn't know that it used workflows in the background. I also didn't know about the requirement to not use Write-Host. Thanks!

You must be logged in to reply to this topic.