Solved

Powershell to execute simultaneous remote installation across multiple servers

Posted on 2014-12-09
3
1,006 Views
Last Modified: 2014-12-11
I am trying to remotely execute an installation file (.msi) on about 500 windows servers.

I tested using psexec and it worked fine. I ran the following script which managed to install the msi which resides on my network share on both remote computers below. After the .msi there are some flags I need to specify since it is a static installation. Again the psexec script below works with on exception. It install this on one computer at a time. It executes on x.x.x.23 once its done it runs on x.x.x.24...

psexec \\172.22.173.23,172.22.173.24 -u MYUSERNAME -p MYPASSWORD msiexec.exe /i \\172.22.173.22\pack\splunkforwarder-6.2.0-237341-x64-release.msi RECEIVING_INDEXER="172.22.173.22:9997" WINEVENTLOG_APP_ENABLE=1 WINEVENTLOG_SEC_ENABLE=1 WINEVENTLOG_SYS_ENABLE=1 AGREETOLICENSE=YES /quiet


I was wondering if using powershell (more powerful) i can remotely execute this .msi file/flags on all my servers ( or perhaps 50 - 100 at a time) simultaneously?

I would rather have them call the .msi on the share concurrently rather than wait for one to be installed and then move on to the next server like when using psexec.

If its possible with powershell, where would I be able to find this script?

many thanks,

t
0
Comment
Question by:tobe1424
3 Comments
 
LVL 16

Assisted Solution

by:Mike T
Mike T earned 250 total points
ID: 40491061
Hi,

I am wondering why you are doing the install this way in the first place? This sounds like a task for assigning with GPO, rather than a script. Even using a one-off job, GPO is more manageable.

To answer your question you won't find a script for something that basic. The command  is:

Invoke-Command -ComputerName server1 -ScriptBlock {hostname}

If you want to run on multiple machines there are ways to pass a CSV but I think you would be better placed to use a GPO to run on a group of machines.

Mike
0
 

Author Comment

by:tobe1424
ID: 40491687
Hi Mike,

Thanks for the feedback.

The issue is that the servers cannot be rebooted. In order to deploy this via a start up script like I first intended to, the servers have to be rebooted. The application itself doesn't require a reboot. However, if I am not mistaken, the gpo will require a reboot in order for the software installation to commence

So installing using psexec only calls one server at a time since it doesnt handle multi threading too well.

Based on your input i did find the script below from the link.

http://technet.microsoft.com/en-us/library/dd819505.aspx

invoke-command -computername Server01, Server02 -filepath c:\Scripts\DiskCollect.ps1

Would something like this work?

invoke-command -computername Server01, Server02 -filepath msiexec.exe /i \\172.22.173.22\pack\splunkforwarder-6.2.0-237341-x64-release.msi RECEIVING_INDEXER="172.22.173.22:9997" WINEVENTLOG_APP_ENABLE=1 WINEVENTLOG_SEC_ENABLE=1 WINEVENTLOG_SYS_ENABLE=1 AGREETOLICENSE=YES /quiet


I am trying to call the msiexec
0
 
LVL 39

Accepted Solution

by:
footech earned 250 total points
ID: 40492565
Unfortunately it's not as simple as that.

What I have seen doing installs via PS Remoting
- you have to use CredSSP if accessing a UNC path in the remote session.  So of course this entails setting up PS Remoting and delegation of credentials.
- you have to first create sessions which Invoke-Command will use instead of using the -ComputerName parameter which tears down the session as soon as it's finished running commands.  It doesn't seem to allow enough time for the install to complete and so cuts it off.  You still have to clean up the sessions after doing all the installs.  Depending on the number of computers you're establishing sessions to, it can be tricky managing the sessions (you can only have so many open).
- when running non-PowerShell commands, you may have to play around with syntax to get parameters passed to the command properly.

Here's the basic structure that you would need.
$cred = Get-Credential
$sessions = New-PSSession -ComputerName (Get-Content servers.txt) -Credential $cred -Authentication Credssp

#up to the .MSI this should work, don't know if syntax would have to adjusted for any of the other parameters
$scriptblock = {
  msiexec.exe /i \\172.22.173.22\pack\splunkforwarder-6.2.0-237341-x64-release.msi RECEIVING_INDEXER="172.22.173.22:9997" WINEVENTLOG_APP_ENABLE=1 WINEVENTLOG_SEC_ENABLE=1 WINEVENTLOG_SYS_ENABLE=1 AGREETOLICENSE=YES /quiet
}
Invoke-Command -Session $sessions -ScriptBlock $scriptblock

# after enough time has passed to allow all the installs to complete
Get-PsSession | Remove-PsSession

Open in new window

0

Featured Post

Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

Join & Write a Comment

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now