Author Posts

August 7, 2014 at 11:58 am

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

August 8, 2014 at 1:00 am

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.

August 8, 2014 at 2:20 pm

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!