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.
You can use Inline