Hello Nayan,
Unlike Bash, PowerShell (PS) stores environment variables in a separate namespace from "regular" variables. The code sample you provided references regular variables, not environment variables.
The easiest way I know of to work with (existing) environment variables in PS is to use the "env" PS drive. This drive provides a shortcut for access environment variables. Some examples:
# Print the value of the "myVar" variable in the current scope:
Write-Output -InputObject $myVar
# Print the value of the "myVar" environment variable:
Write-Output -InputObject $env:myVar
# List all environment variables:
Get-ChildItem -Path env:
With that said, this isn't really a GoCD question. If you have further questions about getting PS to do the things you want it to do, I recommend posting your question(s) to a PowerShell-specific forum.
Regards,
Jason Smyth