# Define the script to run in the background
$script = {
Param(
[string]$parameter1,
[int]$parameter2
)
# Your script code goes here
Write-Host "Script executed in the background with parameter1: $parameter1, parameter2: $parameter2"
}
# Start the script as a background job
$job = Start-Job -ScriptBlock $script -ArgumentList "Value1", 123
# Do other tasks while the script runs in the background
# Wait for the background job to complete
$job | Wait-Job
# Retrieve the output from the background job
$output = Receive-Job $job
# Display the output
Write-Host $output