locked
Invoke-command need to add a log file piece to script RRS feed

  • Question

  • Below is the script I want to use, I need to add an item on this to allow me to create a log file to show success or failures and put it in the c:\temp folder... How do I add this command/ switch?

     

    $comp = get-content "C:\PClist.txt"

    invoke-command -computername $comp -asjob {start-process c:\job.bat}

    Wednesday, March 28, 2018 5:26 PM

Answers

  •  How do I add this command/ switch?

    Jedi_Administrator

    You should use "The force" to achive what you need!  ;-)  :-D

    It depends pretty much what your cmd file looks like or what it does. In general you can use Out-File to output whatever you like to a file.


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    Wednesday, March 28, 2018 5:33 PM
  • Just output the results to a file:

    $job = invoke-command -computername $comp -asjob {start-process c:\job.bat} 

    Wait-Job $job | Receive-Job | Out-File file.log


    \_(ツ)_/


    • Edited by jrv Wednesday, March 28, 2018 5:37 PM
    • Marked as answer by Jedi_Administrator Wednesday, March 28, 2018 7:15 PM
    Wednesday, March 28, 2018 5:33 PM

All replies

  •  How do I add this command/ switch?

    Jedi_Administrator

    You should use "The force" to achive what you need!  ;-)  :-D

    It depends pretty much what your cmd file looks like or what it does. In general you can use Out-File to output whatever you like to a file.


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    Wednesday, March 28, 2018 5:33 PM
  • Just output the results to a file:

    $job = invoke-command -computername $comp -asjob {start-process c:\job.bat} 

    Wait-Job $job | Receive-Job | Out-File file.log


    \_(ツ)_/


    • Edited by jrv Wednesday, March 28, 2018 5:37 PM
    • Marked as answer by Jedi_Administrator Wednesday, March 28, 2018 7:15 PM
    Wednesday, March 28, 2018 5:33 PM