In the second stage, it would suffice to just say:
Write-Host 'reference: $(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
comes from, but it should be omitted.
The output should then be:
Write-Host 'reference: potato'
I'm also not sure what "
" in the first stage means or does, but I think it can be omitted as well.