Azure-functions-host: Powershell: Write-Host throws an error

Created on 19 Aug 2016  路  9Comments  路  Source: Azure/azure-functions-host

If I do this: Write-Host "hello", I get this error:

Write-Host : 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. at run.ps1: line 1

lang-PowerShell

All 9 comments

I assume you're trying to write some debug output to logs, not to an output binding? @tohling what is the right way to do that?

Correct -- just trying to write out to the logs. I can get around it by just using a string by itself "hello" but thought others may be using Write-Host, especially if they're trying to re-use existing scripts.

You mean to write a console entry, you just put a string "hello" on a single line?

Yeah -- here's my script that logs:

for($i=1; $i -le 10; $i++)
{
    "powershell running " + $i
    Start-Sleep -s 1
}

Probably by design, but we'll let Ling confirm

Yes, you will not be able to use Write-Host as Functions operate in a multi-tenant environment and PowerShell commands will not be able to interact directly with the host. Use Write-Output instead.

Close by design

Why do I find this AFTER I spend 2 hours bashing my head :'(
Let's put that in the documentation.

image

@johnnliu, yes we will provide a more comprehensive set of documentation soon. Thank you for your patience.

Was this page helpful?
0 / 5 - 0 ratings