I am trying to run the PowerShell script, which I have, on multiple computers simultaneously. Currently, I'm using PowerShell version 5.
I want to know is it possible to run it without background process, to check for the better understanding of logs.
$computers = @("Hostname1", "Hostname2", "Hostname3")$scriptPath = "C:\Projects\Scripts\Environment\InstallEnvironment.ps1"$scriptBlock = { param ( [string]$scriptPath ) try { # Execute the script& $scriptPath } catch { Write-Host "Error occurred on $($env:COMPUTERNAME): $_" }}foreach ($computer in $computers) { Start-Job -ScriptBlock $scriptBlock -ArgumentList $scriptPath -Name $computer}while (Get-Job -State Running) { Start-Sleep -Milliseconds 100}Get-Job | Receive-JobGet-Job | Remove-Job
Any assistance is much appreciated.