Create environment variable in powershell to persist between steps

Hi,

I have used the below code in bash to create an environment variable to be used in another step.

echo 'export VERY_IMPORTANT=$("somevalue")' >> $BASH_ENV

However I cannot seem to find a way to do this in PowerShell. Is this possible?

Thanks!

1 Like

I have the same issue and have also tried writing the environment variable to the PowerShell profile which doesn’t seem to be executed on subsequent steps.

New-Item $Profile.CurrentUserAllHosts -Force
Add-Content -Path $Profile.CurrentUserAllHosts -Value '$Env:BUILD_VERSION = "1.0.0"'

The following returns null when run in a subsequent step.
$Env:$BUILD_VERSION

That is similar to how I have it working. What path does that resolve to?