I previously posted regarding a problem running an executable on a remote computer. That was resolved with th -Wait command.
So now I am having a different issue. the command runs one at a time on each server in the server.text file. The executable that I am running can take hours to complete so I want them to run concurrently on each server in the file. I have tried commands I have found to run parallel unsuccessfully. Any suggestions? This is my script that works well one at a time.
#Variables
$computername = Get-Content c:\shared\servers.txt
$sourcefile = “c:\shared\dummy.exe”
#This section will install the software
foreach ($computer in $computername)
{
$destinationFolder = “\$computer\C$\install”
#It will copy $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $destinationFolder
Invoke-Command -ComputerName $computer -ScriptBlock {
Start-Process ‘c:\install\dummy.exe’ -Wait
}