0

Probably a repetitive question, but need some to-the-point answers as I'm still learning. I want to run the PowerShell script on all remote servers- simultaneously, to install an application. I tried the below cmdlet but it's executing one after the other, and also would like to know the status or job output file. Any help is much appreciated. Thanks

$servers = Get-Content "C:\Dumps\Scripts\servers.txt"

foreach ($server in $servers) {
    Invoke-Command -ComputerName $server -Filepath C:\Dumps\Scripts\CompleteSilent.ps1
}

1 Answer 1

2

Simply use $Servers as the -ComputerName argument. Invoke-Command will run them parallel.

You can adjust the Throttle on the parallelism with the -Throttle parameter.

Invoke-Command -ComputerName $Servers -Filepath C:\Dumps\Scripts\CompleteSilent.ps1

Note: If there are return objects and or screen echoes they may return disordered. It can be handled, but if this is an installation you may not encounter that particular issue.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Is it possible to capture installation status into a log file? PS script contains java and tomcat silent install cmds.
That really depends. If the installer creates a log it'll be independent of the PowerShell command. You'll likely have to handle by copying somewhere...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.