Remote PowerShell Execution Query

Welcome Forums General PowerShell Q&A Remote PowerShell Execution Query

Viewing 1 reply thread
  • Author
    • #264836
      Topics: 1
      Replies: 0
      Points: 7
      Rank: Member

      Hello All,
      Am new to the forum & has been ages since I last wrote a script for any platform, but have been tasked with one in PowerShell recently.

      In brief:
      Running from Server-A (running PS 4.0), I have a listing of server names (700-800) to upload packages to and then execute a PS1 script (from the uploaded packages) on the remote server (Server-X).

      Problem #1:
      How best should I execute the remote .ps1 script (on Server-X) and can this be done in a Unix style background mode ‘&’?
      The remote .ps1 script may take only a few minutes on some servers and take hours on others – hence seeking for a background mode capability.

      I was this morning attempting to use …

      But that isn’t working as I’d hoped.

      Problem #2:
      Am finding that some of the servers I need to connect to are running PS 2.0 – how best to write the scripts to accommodate varying/unknown PS versions?

      Any assistance would be really appreciated.


      • This topic was modified 1 month, 1 week ago by kvprasoon. Reason: code formatting
    • #264842
      Senior Moderator
      Topics: 9
      Replies: 1420
      Points: 5,280
      Helping Hand
      Rank: Community MVP

      Background jobs are created using Start-Job cmdlet in PowerShell and remote executions are triggered using Invoke-Command cmdlet.

      You can use Invoke-Command to trigger the script and no need to use Start-Job as remote executions are always ran in background in the remote node.
      Invoke-Command do have -ComputerName parameter which can take array of computers with a default throttle limit of 32. So when array of computer is passed, the node
      from where the trigger happens will have execution happening in threads per computer. Invoke-Command has a parameter -Disconnected, but this can be used only from PS v4 I think.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.