In the second stage, it would suffice to just say:
Write-Host 'reference: $(MyOutputVariable)'
Since
MyOutputVariable
is the name of your variable and it is literally inserted where you place it, so inside the quotes. I'm not sure where
MyReferenceName
comes from, but it should be omitted.
The output should then be:
Write-Host 'reference: potato'
I'm also not sure what "
isOutput=true
" in the first stage means or does, but I think it can be omitted as well.