How to Install Software on Remote Computers With PowerShell Script

Welcome Forums General PowerShell Q&A How to Install Software on Remote Computers With PowerShell Script

Viewing 2 reply threads
  • Author
    Posts
    • #277404
      Participant
      Topics: 8
      Replies: 23
      Points: 104
      Rank: Participant

      Does anyone happen to know how to install Software on Remote Machines using a PowerShell script?

      If you have an example script it would be awesome.

    • #277566
      Participant
      Topics: 10
      Replies: 46
      Points: 277
      Helping Hand
      Rank: Contributor

      Invoke-Command is used to run PowerShell commands on a remote computer.

      Start-Process will execute the installer for the software you are trying to install.  For this you need the command line installation parameters, usually something like this:  Start-Process -Wait -Verb RunAs -FilePath msiexec.exe -ArgumentList “installer.msi /i /qn /norestart”

    • #280869
      Participant
      Topics: 0
      Replies: 5
      Points: 21
      Rank: Member

      If you already have the file on the remote system, we can run it with Invoke-Command.

      Invoke-Command -ComputerName server01 -ScriptBlock {
      c:\software\installer.exe /silent
      }
      There are two important details to be aware of right away.

      The first detail is that you need to maintain a remote session while the installer is running. If the installer does not block execution (it returns control back to the shell while it executes), your script may finish before the installer finishes. This will cancel the install as it closes the remote session.

      You will need to call Start-Process -Wait if you are having that issue.

      Invoke-Command -ComputerName server01 -ScriptBlock {
      Start-Process c:\windows\temp\installer.exe -ArgumentList ‘/silent’ -Wait
      }

      I hope this information will be helpful!

      Ben Martin

      • #281108
        Participant
        Topics: 8
        Replies: 23
        Points: 104
        Rank: Participant

        Hi Ben,

        This information is most helpful.  I do have a question about this and the entire process for that matter.

        Do each of the remote target machines need to have PSRemoting enabled for this to work?

         

        Thanks,

        Orlando

      • #281138
        Participant
        Topics: 4
        Replies: 422
        Points: 734
        Helping Hand
        Rank: Major Contributor

        Hi Orlando,

        I doubt you’ll get a reply from that user.  I have reported all the account’s replies but they haven’t been removed yet; it’s just copying and pasting content from blogs that appears to be semi-relevant to the questions being asked, probably in an effort to get some ‘reputation’ so it can continue to spam the link it included in at least one other post.

        If you found its comment useful, here is the full blog article that it stole the content from:

        https://powershellexplained.com/2017-04-22-Powershell-installing-remote-software/

Viewing 2 reply threads
  • You must be logged in to reply to this topic.