Solved

Powershell to execute simultaneous remote installation across multiple servers

Posted on 2014-12-09
3
1,191 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 17

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 40

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
A brief introduction to what I consider to be the best editor for PowerShell.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

808 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