How to get your PowerShell output to show up in Deployment Log


I wrote some custom PowerShell that calls an exe but the output is not being shown in the Release Management Deployment Log.


Wrap your PowerShell in a function and pass the -Verbose switch.


When Release Management runs your PowerShell it will display anything written with Write-Verbose in the Command Output section of the Deployment Log.  However, the output of exe’s run within a PowerShell script are written to stdout or stderr.  You have to capture the output and write it to Write-Verbose yourself.

function deploy_db





    Write-Verbose "Updating Database"


    $output = & 'C:\Program Files (x86)\Microsoft SQL     Server\120\DAC\bin\SqlPackage.exe' /Action:Publish /SourceFile:$applicationPath\$FileName /TargetConnectionString:"Data Source=$SqlServer;User ID=$UserID;Password=$Password;Initial Catalog=$DatabaseName" 2>&1


    Write-Verbose "$output"


    Write-Verbose "Database Update Complete"



deploy_db -Verbose


In the sample above we are capturing the output of the call to SqlPackage.exe into $output.  The 2>&1 is redirecting stderr to stdout so we will capture any errors as well.  Next we use Write-Verbose to write any values we want to appear in the Command Output of the Deployment Log.  Finally we call ourselves passing in -Verbose.

Comments (5) -

  • Mike

    3/16/2015 3:50:26 PM | Reply

    If I use DSC scripts on premise I also don't get output in the logfiles. In VSO it works. Do you have any idea how I get rm to create log for DSC?

    • Donoavn

      3/16/2015 4:55:03 PM | Reply

      So you are using an on prem RM Server and your not getting the command output. But if you run the same script with RMO it is?

      • Mike

        3/16/2015 7:56:06 PM | Reply

        I have an on prem rm server and deploy to an existing environment. The only output I get is "Copying recursively from \\fileshare\drop\... to C:\Windows\DtlDownloads\...". A similar dsc configuration produces a perfect output in RMO in an azure environmwnt. Both scripts run fine - I can see the result in eventmgr... but a logile would be really helpful.

  • Graham Smith

    3/19/2015 5:49:10 PM | Reply

    To make this work I found statements need to be like this:

    Write-Verbose "Database Update Complete" -Verbose

    Cheers - Graham

  • Beqa

    10/4/2018 11:55:37 AM | Reply

    Graham Smith, adding -Verbose flag did the job for me, thanks

Add comment