execute .bat file on remote computer

Welcome Forums General PowerShell Q&A execute .bat file on remote computer

Viewing 2 reply threads
  • Author
    Posts
    • #222471
      Participant
      Topics: 47
      Replies: 98
      Points: 645
      Rank: Major Contributor

      Hi

      what I want to achieve here is
      connect to the remote computer

      execute a bat file which contains the following code

      showing progress by preference in the console
      once finished the output file needs to be copied to my local machine

      this is what I have sofar

      however when I try to run this code I get this error

      Paul

       

      • This topic was modified 9 months ago by acer460527.
    • #222768
      Participant
      Topics: 0
      Replies: 2
      Points: 12
      Rank: Member

      Hi Paul,

      The error your getting is because you provided an argument that’s not required. Invoke-Command -AsJob does not need a parameter to work. Just remove $remotejob from line 13 and it will run without that error.

      Check out example 8 to see an example of what I mean https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7

      If you want to get the job information just run $remotejob. If you want to get the results of the job run $remotejob | Receive-Job

      Hope this helps

    • #222840
      Participant
      Topics: 47
      Replies: 98
      Points: 645
      Rank: Major Contributor

      twilightScripter thanks for your help

      it’s working now

       

Viewing 2 reply threads
  • The topic ‘execute .bat file on remote computer’ is closed to new replies.