'Pass variable to subscript

I have a simple script in PowerShell with a list and a Job

$file_bme1 = "C:\file1.txt"
$file_bme2 = "C:\file2.txt"
$scriptList =@(
    'C:\Program Files\PuTTY\collection1.ps1'
    'C:\Program Files\PuTTY\collection2.ps1'
);
sleep -seconds 10
Write-Output "Script starting..."
foreach ($i in 1..1){
Write-Output "Loop $i"
$jobs=foreach($script in $scriptList){
    Start-Job -ScriptBlock {& $using:script}
    }
$jobs | Wait-Job | Receive-Job 2>$null
Write-Output "End of Loop $i"
sleep -seconds 30
}
Write-Output "Script completed."

I would like to pass variable $file_bme1 and $file_bme2 to the subscripts (collection1.ps1 and collection2.ps1), but I'm having issues on how to achieve that. Any recommendation?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source