Solved

Install powershell remotely on multiple servers

Posted on 2013-12-09
5
1,502 Views
1 Endorsement
Last Modified: 2013-12-11
Hi all, i have the following script to copy PS3 on to the server but is there a way to install powereshell on all using the command similar to the one below?

thanks

$servers =Get-Content "C:\Users\Downloads\machines.txt"

foreach ( $servers1 in $servers ) {
@"

Displaying for $servers1

"@
 
 $copy2 = Copy-Item -Path C:\IT\Windows6.1-KB2506143-x64.msu "\\$servers1\c$\it" -Recurse
1
Comment
Question by:cwstad2
[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
  • 2
  • 2
5 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 39706396
Using PowerShell to install PowerShell could be difficult ;-). But of course you can use Invoke-Command to remote start the MSU file in silent install mode if you've set up WinRM properly.
BTW, copy-item -recurse for a single file seems to be overkill ...
0
 
LVL 15

Author Comment

by:cwstad2
ID: 39706408
I know im a bit lazy but its over a very low bandwidth connection so it takes a while to log on or to enter-pssession. Can i use the invoke command against a list from the txt file?
0
 
LVL 13

Expert Comment

by:Felix Leven
ID: 39706419
wusa.exe C:\IT\Windows6.1-KB2506143-x64.msu /quiet /norestart

Open in new window

will install the update
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39706519
Invoke-Command takes a list of computer names, so yes, you can do that with a single command after having copied the file to all servers,
Invoke-Command -ComputerName $servers { wusa.exe C:\IT\Windows6.1-KB2506143-x64.msu /quiet /norestart }

Open in new window

or in background (as job) after having copied the MSU to one server.
$servers =Get-Content "C:\Users\Downloads\machines.txt"

foreach ( $server in $servers ) {
@" 

Displaying for $server

"@
 
  $copy2 = Copy-Item -Path C:\IT\Windows6.1-KB2506143-x64.msu "\\$server\c$\it"
  Invoke-Command -Computer $server -AsJob { wusa.exe C:\IT\Windows6.1-KB2506143-x64.msu /quiet /norestart }
}

Open in new window

But that only works that way if you are in the same domain, and not using IP addresses.
0
 
LVL 15

Author Closing Comment

by:cwstad2
ID: 39710831
perfect thanks
0

Featured Post

Independent Software Vendors: 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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
The viewer will learn how to count occurrences of each item in an array.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

630 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