I'm trying to get the value of a variable modified inside a scriptblock:
function Test-Function {
$var = "apple"
Start-Job -ScriptBlock {
$var = "banana"
}
Write-Host "Variable is $var"
}
Test-Function
Variable is: apple
I am trying to get the output 'banana'. Is this possible?