Solved

Powershell to execute simultaneous remote installation across multiple servers

Posted on 2014-12-09
3
1,466 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

628 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