Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Logging PowerShell/Dos output



  • I have a PowerShell script which accepts parameters calling various PowerShell and dos commands. I need to execute this script from build master, so I can pass in various parameters such as %RELNO%.%BLDNO%.

    Because the script is rather complex and will be called from a different applications I want to keep it as a file rather than pasting it into the script box of the Execute PowerShell Script. The script resides on the same server as Buildmaster.

    However passing parameters to a script appears to be problematic in BuildMaster. I have tried both Execute PowerShell Script and Execute Shell Script.

    So far the only I way I can execute this script is via a Execute Command Line action, which passes parameters from BuildMaster to a batch file. This batch file, in turn, executes powershell.exe calling the my PowerShell script with the received parameters .

    So far, so good. However the BuildMaster log only captures some of the output raised from within the PowerShell script. In particular the output from the dos commands executed from within my PowerShell script does not appear in the BuildMaster log

    I have tried various methods from within my PowerShell script (transcript , various piping, etc). Even piping the whole output from the powershell.exe command in my dos batch file. But no matter what I do, it seems that while I can capture or see the output when I run the batch script from windows, it is lost when I call the dos batch file from BuildMaster.

    How can I capture the output? Is there a better way to do this?



  • Hi Tim,

    The way that our powershell action is implemented (see ExecutePowerShellScriptAction.cs), we do use command parameters -- only import the variables that you specify.

    However, now that we're using NET4, it seems possible to use the CommandParameter class.

    In the mean time, you could do something like...

    param(
     [string]$PMyVar1,
     [string]$PMyVar2)
    
    if ($PMyVar1) $MyVar1 = $PMyVar1
    if ($PMyVar2) $MyVar1 = $PMyVar2
    

    And then pass in $MyVar1 as a variable from the BuildMaster action.

    Not sure why output isn't being captured. BuildMaster's execute command line action simply writes whatever is written to the standard output and error streams from the launched process.



  • Greeting..

    I am having similar problems..

    Write-Host and Write-Output do not seem to work..

    I have been able to use Write-Warning and Write-Error but these change the status of the workflow to warning or error in addition to outputting the detail in the log.

    Currently I am using "Write-Warning" but I would rather have a solution that keeps the workflow as a success.

    J.D.



  • @J.D. - can you post this a new question? It may only be tangentially related to the original post in this thread.



Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation