Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    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

    Scheduled Pinned Locked Moved Support
    powershellbuildmaster
    4 Posts 1 Posters 16 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? This user is from outside of this forum
      Guest
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

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

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation