0
votes

I have something like this:

workflow WF {
    foreach -Parallel ($computer in $computers) {
        $results = InlineScript {
            $session = New-PSSession -ComputerName $Using:computer
            return Invoke-Command -Session $session -ScriptBlock {
                 Write-Host "Test"
            }
        }
    }
}

When I run this, I'll get an error:

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
    + PSComputerName        : [localhost]

How can I get the Write-Host output to the computer running the script? Note that I'm returning something else inside the ScriptBlock so I cannot just return the string and Write-Host it.

1
... because the host program or the command type does not support user interaction - don't use Write-Host in a remote session, use Write-Output (or Write-Information if you you're on version 5+) if you want information back from the remote runspace - Mathias R. Jessen
@MathiasR.Jessen That fixed it, thanks! - tyteen4a03

1 Answers

0
votes

You can use Inline

 inlineScript
    {
    Write-Host "Allow"
    }