Execute Script in parallel immedeniantly


Our organisation has a remote button that can be used in a duress situation (e.g. gunman in the building etc.) to activate a silent alarm within the building (flashing light) and also send out an email to staff when the button is pressed.

However if staff don’t have Outlook open they won’t receive the message. I’ve therefore created an application to open on all PCs when the duress button is pressed (triggers an outlook rule to run the application).

I am using PSexec and the below powershell script to launch the application however even when launching the powershell script directly it takes at least 30 seconds to launch the application on the computers.

I am not a great Powershell scripter but I am wondering if someone might know how I can speed up the execution of the program and to run the script in parallel?

Parallel execution of the program is very important as it needs to go to every machine as quickly as possible. Executing on each PC one by one would mean someone might receive the warning 10 minutes later which is not very helpful.

Thanks in Advance!

Get-Content "C:remotecommandpsexeccomputers.txt" | %{ # Define what each job does $ScriptBlock = { C:remotecommandpsexecPsExec.exe -s -i -d \$args "C:WindowsDURESS ALARM.exe" #Start-Sleep 15 } # Execute the jobs in parallel Write-Host $ScriptBlock Start-Job $ScriptBlock -ArgumentList $_ } Get-Job # Wait for it all to complete While (Get-Job -State "Running") { Start-Sleep 10 } # Getting the information back from the jobs Get-Job | Receive-Job 


submitted by /u/danielg174
[link] [comments]

Leave a Reply