Home > Software engineering >  Can't see write-host output in the log when running PowerShell in Azure in "Code Test&qu
Can't see write-host output in the log when running PowerShell in Azure in "Code Test&qu

Time:11-15

I have the simple script in run.ps1

 # Input bindings are passed in via param block.
param($Timer)
# Get the current universal time in the default string format.
$currentUTCtime = (Get-Date).ToUniversalTime()
# The 'IsPastDue' property is 'true' when the current function invocation is later than scheduled.
if ($Timer.IsPastDue) {
    Write-Host "PowerShell timer is running late!"
}
# Write an information log with the current time.
Write-host "PowerShell timer trigger function ran!"
Write-Debug "PowerShell timer trigger function ran! TIME: $currentUTCtime"

Why can I see ""PowerShell timer trigger function ran!" in the log on the bottom?

CodePudding user response:

Thanks @Dilly B, I have reproduced in my environment and got expected results as below:

Firstly, I have used Write-Host and Ouput is displayed in Output Screen as below:

enter image description here

Then I have used Write-Output and got logs of it as below:

enter image description here

Output in logs:

enter image description here

Edit:

enter image description here

enter image description here

enter image description here

  • Related