Remove-Variable: Cannot find a variable with the name ‘SmithySettings_ScriptTokens__ReleaseVersion’
I tried to print all session variables with Get-Variable, it is not there where as when I ran again my app it picked up the right value from the variable. Is there anything wrong I am doing? Thanks for your help
The error is correct . . . your variable isn’t a file. The Remove-Item cmdlet works with many “providers” (file system, registry, etc.). You haven’t specified a provider so the cmdlet assumes a default and looks for a file system object. In your case it’s a file named “SmithySettings_ScriptTokens__ReleaseVersion” in the current directory.
Your second attempt (using a variable named $env) is closer, but still incorrect. The provider name should be “ENV:”. The “$env:” is a variable prefix, not a provider.