Search code examples
azureworkflowazure-runbook

How to get timestamp in Azure runbook workflow


I am trying to get a timestamp when I do write-output lines. I have tries several things, and ending with:

filter timestamp {"$(Get-Date -Format G): $_"}
Write-Output "JOB START BEFORE INLINESCRIPT" | timestamp

But this gives me the error:

The 'timestamp' activity is not supported in a workflow pipeline

What is the proper way to do this?


Solution

  • You should put your code in an InlineScript block, like below:

    workflow MyFirstRunbook-Workflow
    {   
       INLINESCRIPT{
        write-output "hello world"
        filter timestamp {"$(Get-Date -Format G): $_"}
        write-output "JOB START BEFORE INLINESCRIPT" | timestamp
       }    
    }
    

    Test result:

    enter image description here