I'm trying to set an environment variable, in PowerShell, to an empty string. Note that I don't want to unset the environment variable; I want it set but empty. However, PowerShell removes the environment variable entirely if you just set it to the empty string. I've tried the following:
$ENV:VAR=''
$ENV:VAR=[String]::Empty
$ENV:VAR=[NullString]::Value
$ENV:VAR=$null
New-Item -Path ENV:VAR -Value ''
New-Item -Path ENV:VAR -Value [string::Empty]
Each of those (except the last one) caused the variable not to appear in the output of Get-ChildItem -path ENV:. The last one set the environment variable to the literal string [string::Empty], which is definitely not what I wanted.
For completeness:
$PSVersionTable.PSVersion
Major Minor Build Revision ----- ----- ----- -------- 5 0 10586 117
I can see that it's possible to have an empty environment variable, because I have several:
ConEmuANSI ON
ConEmuAnsiLog
ConEmuArgs
ConEmuArgs2
ConEmuBackHWND 0x00F40BFC
Just for reference, I'm actually trying to set the DOCKER_TLS_VERIFY environment variable to an empty string, because docker-compose treats the absence of that variable as indicating that I want to do TLS verification, and the Docker host I'm using has TLS disabled. I've temporarily given up and switched shells.
Set-Item -Path ENV:VAR -Value "`t"