Running 'Start-Process' Remotely: How to Display Standard Output? The 2019 Stack Overflow...

Am I ethically obligated to go into work on an off day if the reason is sudden?

How to delete random line from file using Unix command?

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

How is simplicity better than precision and clarity in prose?

What's the point in a preamp?

Sort list of array linked objects by keys and values

University's motivation for having tenure-track positions

What information about me do stores get via my credit card?

Can the prologue be the backstory of your main character?

How do you keep chess fun when your opponent constantly beats you?

Derivation tree not rendering

Python - Fishing Simulator

How to pronounce 1ターン?

How should I replace vector<uint8_t>::const_iterator in an API?

Would it be possible to rearrange a dragon's flight muscle to somewhat circumvent the square-cube law?

Is a pteranodon too powerful as a beast companion for a beast master?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Does Parliament hold absolute power in the UK?

How to grep and cut numbes from a file and sum them

Can withdrawing asylum be illegal?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Do warforged have souls?

In horse breeding, what is the female equivalent of putting a horse out "to stud"?

First use of “packing” as in carrying a gun



Running 'Start-Process' Remotely: How to Display Standard Output?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Is there anyway to see when a Windows firewall rule was created/enabled using PowerShell v2 or CMD?PowerShell suddenly hangs on executing any commandIs it possible to get the Process ID of an Executable started in a PowerShell script using he 'Call' (`&`) operator?Please explain, simply, dir /b > dirlist.txt with powershellIs my PowerShell execution environment subtly corrupted?How, from a cmd, start a new cmd instance and run a command within?PowerShell: **reading** input from the keyboard AND **redirecting output** to a variable/filePowershell: use a group of dynamically added commands in new windowHow to create a real time refresh of windows 10 Start menuHow do I restore Windows 10 Start button functionality?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







4















I have a PowerShell script for installing software on remote computers.



To date I have been successfully using the following code:



$prog = "ping"
$arg = "localhost"
$computername = "MACHINE01"
invoke-command -computername $computername {param($p,$a)& $p $a} -ArgumentList $prog,$arg


I now need to install an MSI, Eg. 'msiexec /i c:file.msi /passive'.



I cannot get MSIEXEC to treat everything after 'MSIEXEC' as parameters.
Instead, PowerShell just tries to execute it as one big command.
I have had tried numerous things mostly involving the placement of literal quotes but cannot get this to work.



I have now abandoned the call operator (&) in favour of 'Start-Process' which has an '-ArgumentList' parameter.
The MSI now executes correctly. Great!



invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait -redirectstandardoutput c:output.txt; get-content c:output.txt} -ArgumentList $prog,$arg


The problem with 'Start-Process' is that it does not produce any console output when run remotely using 'Invoke-Command'.
I have had to resort to redirecting the output to a file and then reading the file. Is there a better way?










share|improve this question














bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    4















    I have a PowerShell script for installing software on remote computers.



    To date I have been successfully using the following code:



    $prog = "ping"
    $arg = "localhost"
    $computername = "MACHINE01"
    invoke-command -computername $computername {param($p,$a)& $p $a} -ArgumentList $prog,$arg


    I now need to install an MSI, Eg. 'msiexec /i c:file.msi /passive'.



    I cannot get MSIEXEC to treat everything after 'MSIEXEC' as parameters.
    Instead, PowerShell just tries to execute it as one big command.
    I have had tried numerous things mostly involving the placement of literal quotes but cannot get this to work.



    I have now abandoned the call operator (&) in favour of 'Start-Process' which has an '-ArgumentList' parameter.
    The MSI now executes correctly. Great!



    invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait -redirectstandardoutput c:output.txt; get-content c:output.txt} -ArgumentList $prog,$arg


    The problem with 'Start-Process' is that it does not produce any console output when run remotely using 'Invoke-Command'.
    I have had to resort to redirecting the output to a file and then reading the file. Is there a better way?










    share|improve this question














    bumped to the homepage by Community yesterday


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      4












      4








      4








      I have a PowerShell script for installing software on remote computers.



      To date I have been successfully using the following code:



      $prog = "ping"
      $arg = "localhost"
      $computername = "MACHINE01"
      invoke-command -computername $computername {param($p,$a)& $p $a} -ArgumentList $prog,$arg


      I now need to install an MSI, Eg. 'msiexec /i c:file.msi /passive'.



      I cannot get MSIEXEC to treat everything after 'MSIEXEC' as parameters.
      Instead, PowerShell just tries to execute it as one big command.
      I have had tried numerous things mostly involving the placement of literal quotes but cannot get this to work.



      I have now abandoned the call operator (&) in favour of 'Start-Process' which has an '-ArgumentList' parameter.
      The MSI now executes correctly. Great!



      invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait -redirectstandardoutput c:output.txt; get-content c:output.txt} -ArgumentList $prog,$arg


      The problem with 'Start-Process' is that it does not produce any console output when run remotely using 'Invoke-Command'.
      I have had to resort to redirecting the output to a file and then reading the file. Is there a better way?










      share|improve this question














      I have a PowerShell script for installing software on remote computers.



      To date I have been successfully using the following code:



      $prog = "ping"
      $arg = "localhost"
      $computername = "MACHINE01"
      invoke-command -computername $computername {param($p,$a)& $p $a} -ArgumentList $prog,$arg


      I now need to install an MSI, Eg. 'msiexec /i c:file.msi /passive'.



      I cannot get MSIEXEC to treat everything after 'MSIEXEC' as parameters.
      Instead, PowerShell just tries to execute it as one big command.
      I have had tried numerous things mostly involving the placement of literal quotes but cannot get this to work.



      I have now abandoned the call operator (&) in favour of 'Start-Process' which has an '-ArgumentList' parameter.
      The MSI now executes correctly. Great!



      invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait -redirectstandardoutput c:output.txt; get-content c:output.txt} -ArgumentList $prog,$arg


      The problem with 'Start-Process' is that it does not produce any console output when run remotely using 'Invoke-Command'.
      I have had to resort to redirecting the output to a file and then reading the file. Is there a better way?







      powershell unattended






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 '13 at 20:01









      FitzroyFitzroy

      86148




      86148





      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I would try piping it to the tee-object cmdlet, then saving your file there if needbe (I don't know if sending the file output to $null would work, too bad this isn't linux and we could send it to /dev/null, but I digress)



          This is the tee-object cmdlet http://technet.microsoft.com/en-us/library/ee177014.aspx



          invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file c:output.txt} -ArgumentList $prog,$arg


          that's untested code, but that's generally what you would want.



          invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file $null} -ArgumentList $prog,$arg


          might work as well.






          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f527739%2frunning-start-process-remotely-how-to-display-standard-output%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I would try piping it to the tee-object cmdlet, then saving your file there if needbe (I don't know if sending the file output to $null would work, too bad this isn't linux and we could send it to /dev/null, but I digress)



            This is the tee-object cmdlet http://technet.microsoft.com/en-us/library/ee177014.aspx



            invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file c:output.txt} -ArgumentList $prog,$arg


            that's untested code, but that's generally what you would want.



            invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file $null} -ArgumentList $prog,$arg


            might work as well.






            share|improve this answer




























              0














              I would try piping it to the tee-object cmdlet, then saving your file there if needbe (I don't know if sending the file output to $null would work, too bad this isn't linux and we could send it to /dev/null, but I digress)



              This is the tee-object cmdlet http://technet.microsoft.com/en-us/library/ee177014.aspx



              invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file c:output.txt} -ArgumentList $prog,$arg


              that's untested code, but that's generally what you would want.



              invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file $null} -ArgumentList $prog,$arg


              might work as well.






              share|improve this answer


























                0












                0








                0







                I would try piping it to the tee-object cmdlet, then saving your file there if needbe (I don't know if sending the file output to $null would work, too bad this isn't linux and we could send it to /dev/null, but I digress)



                This is the tee-object cmdlet http://technet.microsoft.com/en-us/library/ee177014.aspx



                invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file c:output.txt} -ArgumentList $prog,$arg


                that's untested code, but that's generally what you would want.



                invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file $null} -ArgumentList $prog,$arg


                might work as well.






                share|improve this answer













                I would try piping it to the tee-object cmdlet, then saving your file there if needbe (I don't know if sending the file output to $null would work, too bad this isn't linux and we could send it to /dev/null, but I digress)



                This is the tee-object cmdlet http://technet.microsoft.com/en-us/library/ee177014.aspx



                invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file c:output.txt} -ArgumentList $prog,$arg


                that's untested code, but that's generally what you would want.



                invoke-command -computername $computername {param($p,$a) start-process $p -argumentlist $a -nonewwindow -wait | tee-object -file $null} -ArgumentList $prog,$arg


                might work as well.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 23 '13 at 4:17









                MDMoore313MDMoore313

                4,5192030




                4,5192030






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f527739%2frunning-start-process-remotely-how-to-display-standard-output%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Cannot install PyQt5 The Next CEO of Stack OverflowCannot install tcpreplay 3.4.4cannot...

                    Kapp-Putsch Acontecimentos | Outros artigos | Menu de navegação

                    Why did early computer designers eschew integers? The Next CEO of Stack OverflowWhat register...